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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Call remote twx via XMLHttpRequest will not work

drichter
15-Moonstone

Call remote twx via XMLHttpRequest will not work

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 1
drichter
15-Moonstone
(To:drichter)

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?

Announcements

Top Tags