Want to use REST to send request to External System.
Want to get data from other system using REST
Here is how you can do this....
ThingWorx has ContentLoaderFunctions API which provides services to load or post content to and from other web applications. One can issue an HTTP request using any of the allowed actions (GET, POST, PUT, DELETE).
List of available ContentLoaderFunctions:
Using LoadXML snippet in a custom service to retrieve an XML document from a specific URL
var result = Resources["ContentLoaderFunctions"].LoadXML(params);
The snippet above contains an example of how to format any headers in JSON that need to be passed in, the URL that points directly to some XML document, a password, username, timeout, and ignoreSSLErrors set to false
When LoadXML is exercised it will retrieve the XML document, and this can then be parsed or handled however is necessary
To see the XML document that is returned from this service the service can be called from a third-party client, such as Postman
Note: If a proxy or username and password are required to connect to the URL, those parameter MUST be specified
Using the PostXML snippet in a custom service to send content to another URL, in this example, another service in Composer
Insert the PostXML snippet into a custom service
var content = "<xml><tag1>NAME</tag1><tag2>AGE</tag2></xml>";