Skip to Content

Scripting example in Jitterbit App Builder - Convert binary to response to text

This Plugin script example was used with a Microsoft Azure REST API, and works with a raw Binary response. The Plugin essentially converts the API endpoint response into something that App Builder can consume/read.

For example, if the REST API endpoint returns something like:

"success"

Then the Plugin converts the response to something that App Builder can read, like:

{
"Message": "success"
}

Script example

#r "Newtonsoft.Json.dll"
using System;
using System.Net.Http;
using Newtonsoft.Json;
// Read the response content
var messageBytes = await Response.Content.ReadAsByteArrayAsync();
var message = Convert.ToBase64String(messageBytes);
// Wrap the message in a json formatted text
message = JsonConvert.SerializeObject(new { Message = message });
// Replace the response content with the formatted json
Response.Content = new StringContent(message, null, "application/json");