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

thingworx api 401

dsergio
1-Newbie

thingworx api 401

hi, i have an authentication problem with the rest api.

I made the same http request with postman and i have two possible response (200 or 401).

How this is possible?


This is the tomcat access log:

10.0.0.61 - - [07/Jul/2016:14:39:00 +0200] POST /Thingworx/Things/prova/Services/getData?data=hello&appKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx HTTP/1.1" 401 1192

10.0.0.61 - - [07/Jul/2016:14:39:01 +0200] POST /Thingworx/Things/prova/Services/getData?data=hello&appKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx HTTP/1.1" 200 167

Thank you.

5 REPLIES 5

The TW Authentication process it's a bit weird...

Few things:

  • You should pass as header:
    • Content-Type: application/json
    • Accept: application/json
    • x-thingworx-session: true
    • appKey: yourAppKey
  • If you are doing a logout, better you call it twice, this way it removes the cookie too, otherwise it doesn't removes the cookie and it fails the next time you try to login.
ttielebein
12-Amethyst
(To:dsergio)

Hello,

Are you saying you see one or the other of those two responses per each request, or that somehow two responses are coming back to you?

Is the HTTP/1.1 a part of the request?

Thanks!

Tori

The first.

After restarting tomcat all works, but I don't understand what the problem was.

Thanks.

mhollenbach
5-Regular Member
(To:dsergio)

Even when logging into the browser the authentication dialog box pops up twice, typically, prompting for authentication when there are no active sessions for that user. I'm not entirely sure why that occurs, but that is consistent with the behavior you are seeing when sending that initial REST request as well. I've submitted a JIRA to R&D regarding this issue and this article will be used to update the status of that JIRA.

Meghan

Announcements