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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How can I invoke service by REST API?

anishi
14-Alexandrite

How can I invoke service by REST API?

I'm learning ThingWorx by PTC University.

There is problem in "Editing a Network" in Part 4 of Introduction to ThingWorx 5.4.

I tried to invoke the service by REST API by following.

http://localhost/Thingworx/Networks/AcmeVending/Services/GetNetworkConnections?method=post

This is exactly same as textbook's description but it failed with the message "Invalid Request".

Does someone know what I should do?

ACCEPTED SOLUTION

Accepted Solutions
smanley
14-Alexandrite
(To:anishi)

Are you following the exercises using 5.4, or using the 5.4 directions on a 6.0 or later platform? If you are using 6.0 or later, you will need to enable this request in the platform subsystem. Go to Systems>PlatformSybsystem in composer. Within the subsystem, open configuration and check the box next to Allow Request Method Switch and un-check the box next to Filter Content-Type.

View solution in original post

6 REPLIES 6
smanley
14-Alexandrite
(To:anishi)

Are you following the exercises using 5.4, or using the 5.4 directions on a 6.0 or later platform? If you are using 6.0 or later, you will need to enable this request in the platform subsystem. Go to Systems>PlatformSybsystem in composer. Within the subsystem, open configuration and check the box next to Allow Request Method Switch and un-check the box next to Filter Content-Type.

anishi
14-Alexandrite
(To:smanley)

Thank you, Saeed.

It looks working properly.


paic
12-Amethyst
(To:anishi)

Please note that allow the Request method does add a risk of Cross Site Reference Attacks and as such this is not recommended practice.

Instead use regular REST API calls where the Method is in the header.

anishi
14-Alexandrite
(To:paic)

Hello Pai

Thank you for your feedback.

Do you have any idea for alternative method?


paic
12-Amethyst
(To:anishi)

All it means is that you can't use &method on the URL line. (Thingworx takes that from a regular URL line a GET and applies it as a POST or PUT)

You have to use it as a regular 'Action Header' so that you do a real POST or PUT

Not sure if you use tools like Postman and the like, but that is what you would use for testing.

In an actual program you should be able to form a regular rest call , for example, Thingworx itself has the ContentLoader functions and you can do PostXML for example.

anishi
14-Alexandrite
(To:paic)

Hello Pai

Thank you for your reply.

I understood what you mean. But I could not find the details for necessary HTTP header description for invoking services in TW document like HELP.

Could you give me the instruction description where I should refer, please?


Announcements


Top Tags