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

How can I invoke service by REST API?

SOLVED
Highlighted
Garnet

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How can I invoke service by REST API?

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
Highlighted

Re: How can I invoke service by REST API?

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

Highlighted

Re: How can I invoke service by REST API?

Thank you, Saeed.

It looks working properly.


Highlighted

Re: How can I invoke service by REST API?

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.

Highlighted

Re: How can I invoke service by REST API?

Hello Pai

Thank you for your feedback.

Do you have any idea for alternative method?


Highlighted

Re: How can I invoke service by REST API?

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.

Highlighted

Re: How can I invoke service by REST API?

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

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!