Skip to main content
1-Visitor
December 11, 2015
Question

Handling 302 error with Angular.js connecting to ThingWorx-Login Page

  • December 11, 2015
  • 1 reply
  • 4711 views

Hi,

I am having this 302 (redirect) issue when I want to first connect to my thingworx application via my Angular.js written front-end login page.

Normally, writing an interceptor would take care of this kind of issues in Angular but in my example it doesn't work.

Any ideas?

Thanks.

1 reply

1-Visitor
December 12, 2015

Good question, is there any way to change 302/redirect to 200 via ThingWorx on Login page?

1-Visitor
December 12, 2015

Here's what it looks like we're going to do:

From our Angular.js login page, do a GET to the following location:

http://ourserver/Thingworx/ApplicationKeys/TheUserKey/?userid=Administrator&password=Password

Userid and password from the GET will come from the login form and when the user submit's the GET will occur. Once we get the keyID from the JSON response we'll use that to populate the webpage with subsequent REST API calls.

I'd love to hear back from the Thingworx support team if they know of other customers using Thingworx for just a backend and interacting with the data through REST calls executed client-side via Angular.js.

Nick

5-Regular Member
December 14, 2015

Nick, I do not believe we have any specific known cases where customers are using Angular.js, but there are many customers utilizing REST calls to the Platform to work with the backend data. One quick problem with your GET request though, what you are trying to do is not return an appkey, you are returning the AppKey Thing definition. The call you actually want to make is a POST request: http://ourserver/Thingworx/ApplicationKeys/TestingAppKey/Services/GetKeyID?method=post&userid=Administrator&password=Password Also, if you are going to be making external post requests you will need to go to the Platform subsystem->Configuration and then check the box next to "Allow Request Method Switch" Try that and let me know if it helps any. Meg