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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to call Thingworx Rest API from Javascript

aagrawal-31
1-Newbie

How to call Thingworx Rest API from Javascript

Hi,

I am making REST call from JavaScript to Thingworx Thing to execute service and getting HTTP Status Code 403 - Access to resource forbidden

User has execute service permission also.

var xhttp = new XMLHttpRequest();

xhttp.open("POST", "http://localhost:8080/Thingworx/Things/REST/ServiceDefinitions/service?appKey=5da8484d-2605-458d-af0a-be4d83f5baac", false);

xhttp.setRequestHeader("Content-type", "text/html");

xhttp.withCredentials = true;

xhttp.send();

alert(xhttp.responseText);

Note: Thingworx version 7.4

Please suggest.

1 ACCEPTED SOLUTION

Accepted Solutions

This issue has been resolved.

var xhttp = new XMLHttpRequest();

xhttp.open("POST", "http://localhost:8080/Thingworx/Things/REST/Services/service", false);

xhttp.setRequestHeader("Accept", "application/json");

xhttp.setRequestHeader("Content-type", "application/json");

xhttp.setRequestHeader("appKey", "5da8484d-2605-458d-af0a-be4d83f5baac");

xhttp.withCredentials = true;

xhttp.send();

alert(xhttp.responseText);

View solution in original post

3 REPLIES 3

This issue has been resolved.

var xhttp = new XMLHttpRequest();

xhttp.open("POST", "http://localhost:8080/Thingworx/Things/REST/Services/service", false);

xhttp.setRequestHeader("Accept", "application/json");

xhttp.setRequestHeader("Content-type", "application/json");

xhttp.setRequestHeader("appKey", "5da8484d-2605-458d-af0a-be4d83f5baac");

xhttp.withCredentials = true;

xhttp.send();

alert(xhttp.responseText);

ankigupta
5-Regular Member
(To:aagrawal-31)

Hi Abhishek Agrawal

Please mark your answer as correct to close this Thread.

KSM
14-Alexandrite
14-Alexandrite
(To:aagrawal-31)

But I am getting

ReferenceError: "XMLHttpRequest" is not defined.

Top Tags