How to call external Rest API which accepts headers and body as input in ThingWorx
Applies To
- ThingWorx Platform 8.5 SP5 to 9.3 SP2
Description
- How to call external Rest API which accepts headers and body as input
- Accessing a share point giving error via rest API in ThingWorx
- Below code is working with postman but giving error in ThingWorx
-
var url = 'url of share point'
var header = {};
header['Content-type'] = 'application/x-www-from-urlencoded';type']='application/x-www-form-urlencoded';
var body= {};
body['grant type'] = ]client credentials';
body['client_id']='<your client id>';
body['client_secret']='<your client secret>'; body['resource'] = '<your resource>';
var params = {
headers: header /* JSON */,
url: url /* STRING */,
content: body /* JSON */,
};
// result: JSON
var result = Resources["ContentLoaderFunctions"].PostJSON(params);