Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Good evening,
I am integrating a Thingworx application that I already build up thanks to the academic license. The version of Thingworx that I am currently using is 5.2.0.437. I want to fetch some data that are collected by my thingworx application via a Raspberry Pi plug to a demonstrator that simulate an industrial factory. Every data are stored in a thing called thing0. This thing has several properties such as temperature, pressure, position of a stepper motor, etc.... I plan to fetch this data thanks to the service "QueryPropertyHistory" provided by this thing
My main problem is that I want to use the whole historical values already stored on my thingworx instance in a 3rd party tool: A web application that I have developed.
My requirement is to collect this data via a jQuery call using Ajax. I have read and analyzed every wiki’s topics about the REST API and every discussion dealing with the rest API or AJAX in thingworx community website. I couldn't find a proper answer to this problem.
My first question is: Does the server you provide to me support Cross-origin resource sharing?
Given that I was able to use the REST API thanks to Hurl.it - Make HTTP requests in a perfect way, I assume that the reply to this question is a big YES but when I am doing the same with an ajax request using the same variable I have this error
The ajax request has a semantic without any error. the main problem must come from of a wrong configuration of my instance or an issue of my “HTTP post” request. In order to find a solution, the request is described below:
$.ajax({
type: 'POST',
url : 'http://iitt.cloud.thingworx.com/Thingworx/Things/Thing0/Services/QueryPropertyHistory',
headers : {"appkey": "myappkey"},
dataType:"json",
crossDomain:true,
contentType:"application/json;charset=utf-8",
success: function(data, textStatus, jqXHR)
{
alert(data+textStatus);
; },
error: function (jqXHR, textStatus, errorThrown)
{
alert("error");
},
});
Please give me some lead or the right configuration to call a service from thingworx thanks to ajax. This point is a part of a widespread use of case. With solving it we can enhance the scalability of thingworx in an important way that will really matter and help a lot of users.
Happy new year and thanks you in advance for your support,
Enabling the CORS filter in Tomcat config might fix your issue, please follow this link Enable CORS filter
Hey giri,
I have the same problem as Sylvain Pace and followed the instruction you mentioned. I chose the minimal configuration and still have the same Problem. Do you have an idea what I did wrong?
Yes, it's possible. We have our own frontend that uses Thingworx as the backend, all interaction is through AJAX. We just had to implement a CORS filter in Tomcat and everything works great.
Nick