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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Read Post Response Body

TomerH
12-Amethyst

Read Post Response Body

Hi,

We need to integrate ThingWorx with a company web application.

The application receive json as an input than it returning response with a base64 content inside the body.

Using postman for testing we can see the body in the response.

Our issue is we could not find a way to see the body in the response using ThingWorx service using  ContentLoaderFunctions services like PostJSON.

Anyone know how can we read the body response of a post request using ThingWorx?

 

BR,

Tomer. 

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
TomerH
12-Amethyst
(To:Velkumar)

Hi @Velkumar ,

I am adding 2 images.

first is a postman post request, you can see the pdf in the body.

the second is a ThingWorx request where the body is missing.

 

EDIT:

So found the reason for the missing body.

The PostJSON return only JSON response,

When I used PostBinary it return the pdf output but this way I cannot post my JSON.

I do not understand the limitation that the output need to be as the input but at least now i know the issue.

After changing the application response to JSON it did solve the problem.

 

Best Regards,

Tomer.

View solution in original post

4 REPLIES 4
Velkumar
19-Tanzanite
(To:TomerH)

Hi @TomerH 

 

I've tried with a sample POST JSON API and it is working fine. I'm able to read response from server

 

Velkumar_0-1694522945836.png

 

More Information - How to consume Rest API in Thingworx #thingworx #restapi #iiot #internetofthings - YouTube

 

Could you please tell me your Thingworx version and how you are trying to implement it?

 

/VR

 

TomerH
12-Amethyst
(To:Velkumar)

Hi @Velkumar,

Thank you for the reply.

Lets say the web application returning a binary base64 content similar to my txt attachment and content type is application/pdf

In my system we can also see the reply result.

As you see also at the image you provided there are responseHeaders and responseStatus.

But how can I read the content or the responseBody?

 

If needed, I Will add more images tomorrow to give more context to my question.

Best Regards,

Tomer.

Velkumar
19-Tanzanite
(To:TomerH)

Hi @TomerH 

 

In my example API, the token value is the response from the server side.

 

Here is the best example with multiple key values :

 

Velkumar_0-1694570492791.png

 

API Link - Reqres - A hosted REST-API ready to respond to your AJAX requests

 

Please add images that will help us to understand better.

 

/VR

 

 

TomerH
12-Amethyst
(To:Velkumar)

Hi @Velkumar ,

I am adding 2 images.

first is a postman post request, you can see the pdf in the body.

the second is a ThingWorx request where the body is missing.

 

EDIT:

So found the reason for the missing body.

The PostJSON return only JSON response,

When I used PostBinary it return the pdf output but this way I cannot post my JSON.

I do not understand the limitation that the output need to be as the input but at least now i know the issue.

After changing the application response to JSON it did solve the problem.

 

Best Regards,

Tomer.

Announcements


Top Tags