Monday, 2 February 2026

Calling a REST API using IB_GENERIC & ConnectorRequest

 For a simple REST call, Integration Broker typically requires the creation and configuration of multiple metadata components—Messages, Services, Service Operations, Routings, and Handlers.

The IB_GENERIC service acts as a generic wrapper that enables REST calls without requiring custom service definitions.

IB_GENERIC is delivered by PeopleSoft, it is already registered, secured, and available for use in most environments—significantly reducing setup time.

The ConnectorRequest method is the most commonly used approach when developers want to invoke a REST API directly from PeopleCode. It allows you to:

  • Specify the target URL dynamically

  • Set HTTP methods (GET, POST, PUT, DELETE, etc.)

  • Pass request headers and payloads

  • Receive the response as a string or message object

This example demonstrates how to send an SMS using a third-party REST API directly from PeopleCode without creating any Integration Broker metadata (Service, Operation, Routing, etc.).
The call is executed using the delivered IB_GENERIC service and the %IntBroker.ConnectorRequest method.


Local Message     &reqMsg, &respMsg;
Local boolean     &ok;
Local string      &authToken, &requestPayload, &responseText;
Local JsonObject  &jsonMessage, &jsonGlobals, &jsonRoot;
Local JsonArray   &jsonNumbers;
Local JsonParser  &jsonParser;
Local Record      &logRec;

&jsonMessage = CreateJsonObject();
&jsonGlobals = CreateJsonObject();
&jsonNumbers = CreateJsonArray();

Local string &sender = "M001";
Local string &number = "00334405946";
Local string &messageText = "Test SMS";

&jsonNumbers.AddElement(&number);


&jsonMessage.AddProperty("text", &messageText);
&jsonMessage.AddProperty("numbers", &jsonNumbers);
&jsonMessage.AddProperty("number_iso", "PK");
&jsonMessage.AddProperty("sender", &sender);

&jsonGlobals.AddProperty("number_iso", "PK");
&jsonGlobals.AddProperty("sender", &sender);

&requestPayload =
   "{""messages"": [" | &jsonMessage.ToString() | "], " |
   """globals"": " | &jsonGlobals.ToString() | "}";


/* Base64-encoded API Key + Secret */
&authToken = "QnhyaUgwTDNtQVV1c9898989898..";


&reqMsg = CreateMessage(Message.IB_GENERIC);

/* Tell Integration Broker to use HTTP */
&reqMsg.IBInfo.IBConnectorInfo.ConnectorName      = "HTTPTARGET";
&reqMsg.IBInfo.IBConnectorInfo.ConnectorClassName = "HttpTargetConnector";

&ok = &reqMsg.IBInfo.IBConnectorInfo.AddConnectorProperties(
         "Method", "POST", %HttpProperty);

&ok = &reqMsg.IBInfo.IBConnectorInfo.AddConnectorProperties(
         "URL",
         "https://api-sms.4PK.com/api/v1/account/area/sms/send",
         %HttpProperty);

/* HTTP Headers */
&ok = &reqMsg.IBInfo.IBConnectorInfo.AddConnectorProperties(
         "Authorization", "Basic " | &authToken, %Header);

&ok = &reqMsg.IBInfo.IBConnectorInfo.AddConnectorProperties(
         "Content-Type", "application/json", %Header);


&reqMsg.SetContentString(&requestPayload);

/* Send REST request synchronously */
&respMsg = %IntBroker.ConnectorRequest(&reqMsg, True);


&responseText = &respMsg.GetContentString();

&jsonParser = CreateJsonParser();
&jsonParser.Parse(&responseText);
&jsonRoot = &jsonParser.GetRootObject();


If &jsonRoot.GetProperty("code") = "200" Then

Messagebox(0,"",0,0,"Success");

ELSE
Messagebox(0,"",0,0,"Message Not delivered.");

   Return False;
End-If;