Skip to main content
1-Visitor
June 12, 2018
Question

Call remote twx via XMLHttpRequest will not work

  • June 12, 2018
  • 1 reply
  • 878 views

Hey guys,

 

I have a small 2D application with a button. If I click the button the js-methode connectToTWX will call:

 

$scope.connectToTWX = function() {
 var xhttp = new XMLHttpRequest();
 var url = "http://xxxxx:8080/Thingworx/Things/RequestThing/Services/SayBla";
 
 xhttp.setRequestHeader("Content-Type", "application/json");
 xhttp.setRequestHeader("appKey", "xxxxxx");
 xhttp.setRequestHeader("Accept", "application/json");
 
 
 xhttp.open('POST', url, false);
 xhttp.onload = function () {
 if (xhttp.readyState === xhttp.DONE) {
 if (xhttp.status === 200) {
 console.log(xhttp.response);
 console.log(xhttp.responseText);
 
 $scope.app.params['ServiceResult'] = xhttp.responseText;
 }
 }
 };
 xhttp.send("{ }");
}

This code send a post-request to a twx server but nothing is happen. I don't get an error or something in log of the twx server. I'm not sure what happen or what can be wrong.

 

PS: I can request the server via Request Maker from my develope pc and this works.

1 reply

drichter1-VisitorAuthor
1-Visitor
June 13, 2018

Now its work but only if I download the Experience. But it still does not work properly. In Application Log I get a warning:

[SECURITY FAILURE Anonymous:null@unknown -> /ExampleApplication/IntrusionDetector] Invalid input: context=HTTP header value: referer, type(HTTPHeaderValue_referer)=^([a-zA-Z0-9()\-=\*\.\?;,+\/:&_ ]|%[a-fA-F0-9]{2})*$, input=file:///data/data/com.ptc.vuforiaview/files/offlineProjects/project15/index.html?expId=1#/Home

and an error:

Error occurred while validating HTTP header: referer

How can I fix this?