Skip to main content
14-Alexandrite
September 17, 2015
Solved

How can I invoke service by REST API?

  • September 17, 2015
  • 6 replies
  • 4699 views

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?

Best answer by smanley

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.

6 replies

smanley5-Regular MemberAnswer
5-Regular Member
September 17, 2015

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.

anishi14-AlexandriteAuthor
14-Alexandrite
September 24, 2015

Thank you, Saeed.

It looks working properly.


1-Visitor
September 21, 2015

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.

anishi14-AlexandriteAuthor
14-Alexandrite
September 24, 2015

Hello Pai

Thank you for your feedback.

Do you have any idea for alternative method?


1-Visitor
September 24, 2015

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.