Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
var request = {
    type: 'callout',
    object: '',
    data: {
       resource: 'https://my.org.instance.salesforce.com/api/resources',
       options: {
           method: 'POST', // or GET, PUT, DELETE, etc...
           headers: { // header name-value pairs, as shown below
              Authorization: 'Bearer AABBEEAARREERRTTOOKKEENN....',
              Content-Type: 'application/json', // with Salesforce POST/PUT requests this will most often need to be 'application/json'
           },
           body: 'my post content body!', // this should ALWAYS be a string value- use JSON.stringify or similar to create JSON from javascript objects
       }
    }     
};
pulsarBridge.sendRequest(request, function (result) {
   if (result.type === 'calloutResponse') {
      var response = result.data;
      console.log('Response Status Code: '+response.status); // string
      console.log('Response Data:'+response.body); // string
      
   }
   else {
      console.log('failed: '+ result.data)
   }
});

...