Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

PostJSON and PutJSON in ThingWorx 9.2


PostJSON and PutJSON in ThingWorx 9.2



How to use these two services of contentloaderfunctions.


We need to pass body as json for getting the response.


Please share the examples of both services especially PUT.


Thanks in advance.


I don't have an example of PUT but it should be very similar to the Post Example.  For context the example below is making a post request to get an application TOKEN back and setting some thing properties.

	let content = {
		"Username": me.username,
		"Password": me.password
	var response = Resources["ContentLoaderFunctions"].PostJSON({
		ignoreSSLErrors: true,
		url: me.baseURL + me.tokenEndpoint /* STRING */ ,
		content: content,
		contentType: "application/json"
	var now = new Date();
	if (response.body.token && response.body.token != "") {
		me.token = response.body.token;
		me.lastSuccessfulAPICall = now;
		me.tokenExpirationDate = dateAddHours(now, me.tokenLifetimeHours);
		result = true;
catch (err) {
	logger.error( + ", error in GetToken service: " + err);





24-Ruby II

Here are some helpful materials:


"REST API Overview and Examples":


"How to call the RESTful API in a ThingWorx platform service":


"ThingWorx: Difference between GET, POST, and PUT REST methods": 


"How to Post XML or JSON Content to a Custom Thingworx Service via REST API":


"ThingWorx: Post JSON to a service that accepts JSON as an input parameter":


Hi @RK_0705 ,


Try something like this:


var headers = {
	"header1": me.header1,
	"header1": me.header2

var body= {
	"param1": me.param1,
	"param2": me.param2

var directURL = "<Your_Endpoint_URL>";

// It returns JSON
var result = Resources["ContentLoaderFunctions"].PostJSON({
	url: directURL /* STRING */,
	content: body /* JSON */,
	headers: headers /* JSON */,
	useProxy: true /* BOOLEAN */,


Note: I created header and body parameters as a Thing properties, but you can pass them as a service parameters too. Hope this helps.




Top Tags