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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Rest API Call

krishnakomal123
14-Alexandrite

Rest API Call

My requirement is to call a url using GET method and it has body as JSON with two parameters.I tried with almost all contentloadersfunctions available but it is throwing error as Invalid API key.It is actually a No Auth call.Please help me how to achieve this.

 

 

Note: I tried using Postman and I am getting result json when tried GET request with input body as json

ACCEPTED SOLUTION

Accepted Solutions

You can create an extension yourself then if you're allowed to. It's literally one method that needs to be copied and extended by two lines.

You can create a ticket with support but most probably they will tell you the same.

Again, check first if this really is the issue because the error message doesn't fit the problem description.

View solution in original post

5 REPLIES 5

Hi @krishnakomal123  Can you take a look at the below article?

https://www.ptc.com/en/support/article/CS329281

I need to make GetJSON() request but there is no parameter to provide body as content as the snippet doesnt allow it.

 

If I execute the service ,it is giving error.

It is very unusual for a GET to have a body. See https://stackoverflow.com/a/983458 : "So, yes, you can send a body with GET, and no, it is never useful to do so."  This is why GetJSON does not support it, even when HTTP spec allows it.

 

Your error message "Invalid API key" though indicates a different problem. You say it's no Auth, but apparently an API key is expected. Maybe you can log the request on server side to see the difference to the Postman request.

 

If you MUST run a GET with a body, try using ExecuteHttpRequest from this extension https://github.com/ptc-iot-sharing/ContentLoaderExtendedTWX (might need to update the code, not sure, you'll have to try yourself).

 

 

krishnakomal123
14-Alexandrite
(To:Rocko)

I think this extension is not from PTC authorized or provided.I can't use them due to security reasons.Kindly help me how to achieve the same using inbuilt thingworx capabilities

You can create an extension yourself then if you're allowed to. It's literally one method that needs to be copied and extended by two lines.

You can create a ticket with support but most probably they will tell you the same.

Again, check first if this really is the issue because the error message doesn't fit the problem description.

Announcements


Top Tags