cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
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

How to call services from a thing and return JSON format through REST?

acc
7-Bedrock
7-Bedrock

How to call services from a thing and return JSON format through REST?

Hello,

I created a thing with services that able to return a INFOTABLE.

I did tried to create another services that used .ToJSON() and return result in JSON base type.

Both way i couldn't get the result in JSON format when i use postman GET method.Untitled.jpg

REST return  Unexpected 'I' and i don't know what is this mean.


Can somebody tell me how to make it?

Thanks in advanced!

ACCEPTED SOLUTION

Accepted Solutions
ttielebein
14-Alexandrite
(To:acc)

Calling services via REST API are POSTs not GETs. You need to change the type to POST and provide a content-type (likely just application/json). Hope this helps!

View solution in original post

3 REPLIES 3
ankigupta
12-Amethyst
(To:acc)

Hi Ang CC​, Try running the service directly from the composer and check result. Also, make sure to set datashape of the infotable in the script itself.

Check Application logs/Script logs for any error(s).

I hope it helps.

Thanks,

Ankit Gupta

ttielebein
14-Alexandrite
(To:acc)

Calling services via REST API are POSTs not GETs. You need to change the type to POST and provide a content-type (likely just application/json). Hope this helps!

acc
7-Bedrock
7-Bedrock
(To:ttielebein)

Thanks Tori Tielebein​, POST is the correct way with the header content-type.

Announcements


Top Tags