Invoke REST Endpoint With Plain Text Payload

July 1, 2020 | 4 minute read
Greg Mally
Consulting Solutions Architect
Text Size 100%:

The focus of this blog is to detail the steps necessary to invoke a REST endpoint from OIC where the payload is a plain text string.  This seems fairly straightforward and can be done from the OIC REST Adapter, but the setup/mapping is not as easy as the ole drag-and-drop.  The details provided assume that you have an existing integration with a REST connection configured for Invoke (i.e., OIC will be calling some REST endpoint).

Configure REST Endpoint

When configuring an invoke to a REST endpoint in OIC, the wizard takes you through a series of steps that will capture details on how to make the REST call. For this use case where we are invoking the REST endpoint with a string payload, we will focus on the "Request" panel of the Configure REST Endpoint wizard.  The following screenshot highlights the important details that need to be set for the string payload:

Notice that the combination of Binary payload format with Other Media Type allows us to specify any Media Type we want. Since we are sending a plain string for the payload, we are setting the Media Type to text/plain.  However, if you want to try an experiment where you dynamically build a JSON payload as a string for the REST endpoint, you could set the Media Type to application/json.  The Media Type you provide will be the value of the content-type header for the REST call.

Payload Mapping

When opening up the mapper for the REST invoke that was just configured, you will see that the Target payload only has a streamReference for the mapping:

This make sense since the payload format was set to Binary, but our challenge is we have a plain text string we need to map to something that is expecting a reference.  If you go looking for something to convert a string to a reference, you will not find anything.  However, you might find something called decodeBase64ToReference in the Functions:Now, if you continue looking in the Functions for something Base64 you will find a function called encodeBase64:

At this point, you may have already figured out what we are going to do to get the necessary reference.  But just in case, here is a detailed screenshot:

Notice that the plain text string is first being encoded to Base64 and then decoded from Base64 to a reference.  Once this mapping is setup/configured, you can Test the mapping in OIC to see what the results will look like:

Now you can save and activate your integration for a quick test.

Test/Validate Integration

The integration that was created for this blog is using a mock API site called Beeceptor (  This site will allow us to see the details of the REST call coming from OIC.  But before we look at the mock API, we first need to trigger our integration to make OIC call Beeceptor.  To do this, the integrated OIC console REST integration tester was used (but you can use whatever you are most comfortable with):

Now, if we go to Beeceptor we can review the details of the Request Body and the Headers:

As you can see, the Request Body is indeed the plain text payload message that we provided and the "content-type" is "text/plain".

I do hope that you have found this helpful and I appreciate any questions/feedback below.

Greg Mally

Consulting Solutions Architect

Previous Post

Knowledge Graph Modeling: Introduction to gist (and buckets)

Michael J. Sullivan | 4 min read

Next Post

Measuring results in Classifiers with Precision and Recall

Rajesh Chawla | 2 min read