3 Replies Latest reply on Jul 24, 2017 9:35 AM by mludyga RSS
    pacesylv Newbie

    REST API integration via AJAX in a 3rd party tool and CORS

    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 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

    request status thingworx issue.JPG

    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:



        type: 'POST',

        url : 'http://iitt.cloud.thingworx.com/Thingworx/Things/Thing0/Services/QueryPropertyHistory',

        headers : {"appkey": "myappkey"},




        success: function(data, textStatus, jqXHR)



    ;    },

        error: function (jqXHR, textStatus, errorThrown)







    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,