Skip to main content
1-Visitor
December 26, 2016
Solved

Thingworx REST Call not working with a different browser, as well as Python

  • December 26, 2016
  • 5 replies
  • 3276 views

Basically, I'm trying to demo by connecting an ultrasonic sensor to my local H2 based Thingworx Copy.

When running Thingworx on localhost on Chrome, On a new tab, If I try to run this URL below to run service which sets the value of my Ultrasonic Sensor:-

http://localhost:8080/Thingworx/Things/UltraSonicSensor/Services/setDistance?appKey=6cc0dd07-c78a-4548-9109-b2c9cbe7298e…

Then it works and mashup also updates.

However, if I try to run the same link with another browser, it doesnt work. Also, if I try to run this same link  with Python using requests.post("http://localhost:8080/Thingworx/Things/UltraSonicSensor/Services/setDistance?appKey=6cc0dd07-c78a-4548-9109-b2c9cbe7298e…"), It still doesn't work.

Please help.

Best answer by supandey

Muhammad, you might want to recheck the appKey as Dinesh has mentioned, additionally try testing your REST call using Postman it should be really fast and easy to debug the issue.

It could be possible that it works under Chrome in different tab because the session has the require data to authenticate, did you test in the Incognito Mode?

5 replies

1-Visitor
December 26, 2016

Hi Muhammad Hassan,

     you should do small change  subsystem,if you are using 6.0 or later. you should do this,

Go to Systems> subsystem>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. refer the attachment.


platformSubsystem.PNG

Thanks,

DINESH


mhassan11-VisitorAuthor
1-Visitor
December 26, 2016

I've already done that configuration in my browser.

I receive no errors when I use Chrome to execute the command. (When thingworx local instance is running on Chrome)

This is the error I get when I try to run it in Firefox:-

This is the error I get in Python as well:-

1-Visitor
December 26, 2016

Hi Muhammad Hassan,

         configuration was correct. I think you should check the AppKey. you should also check the current user (loggedin) has  Appkey or not?

might be this will be reason you will gettting this error.

Thanks

DINESH

mhassan11-VisitorAuthor
1-Visitor
December 26, 2016

It seems I was using wrong App Key =P..

Positive point I noted from this thread is that even if you put wrong app key in the same session which is authenticated, It still works even if you're using wrong app key.

Thanks for the help Guys.