5 Replies Latest reply on May 31, 2017 8:02 AM by carlesc RSS
    gfiore Newbie

    RestApi from ThingWorx to external Platform

    I need to send some property related to a Thing to an external platform, using RESTAps using the PUT method. Can you have an example of how to use the parameter function that you need to use in the PUTJSON snippet?

     

    var params = {

      proxyScheme: undefined /* STRING */,

      headers: undefined /* JSON */,             

      ignoreSSLErrors: undefined /* BOOLEAN */,

      useNTLM: undefined /* BOOLEAN */,

      workstation: undefined /* STRING */,

      useProxy: undefined /* BOOLEAN */,

      withCookies: undefined /* BOOLEAN */,

      proxyHost: undefined /* STRING */,

      url: undefined /* STRING */,

      content: undefined /* JSON */,

      timeout: undefined /* NUMBER */,

      proxyPort: undefined /* INTEGER */,

      password: undefined /* STRING */,       

      domain: undefined /* STRING */,

      username: undefined /* STRING */       

    };

     

     

    // result: JSON

    var result = Resources["ContentLoaderFunctions"].PutJSON(params);

     

    example of data :

     

    Temperature : 10

    Pression :       25

     

    Nome Thing P1

     

    What are the parameters required for data transfer and how should they be configured?


     

    thanx

    Giuseppe Fiore

      • Re: RestApi from ThingWorx to external Platform
        carlesc Ninja

        You have it a sample on previous params set variable.

          • Re: RestApi from ThingWorx to external Platform
            gfiore Newbie

            Hi, Carles

             

            These are properties with the values to be transferred.

             

            Thing Name : P1

            Property :  Temperature       Value :10

            Property :  Pression           Value : 25

             

            Do you mean these parameters?

             

            thnx

            Giuseppe

              • Re: RestApi from ThingWorx to external Platform
                carlesc Ninja

                No I mean this variable:

                 

                var params = {

                  proxyScheme: undefined /* STRING */,

                  headers: undefined /* JSON */,            

                  ignoreSSLErrors: undefined /* BOOLEAN */,

                  useNTLM: undefined /* BOOLEAN */,

                  workstation: undefined /* STRING */,

                  useProxy: undefined /* BOOLEAN */,

                  withCookies: undefined /* BOOLEAN */,

                  proxyHost: undefined /* STRING */,

                  url: undefined /* STRING */,

                  content: undefined /* JSON */,

                  timeout: undefined /* NUMBER */,

                  proxyPort: undefined /* INTEGER */,

                  password: undefined /* STRING */,      

                  domain: undefined /* STRING */,

                  username: undefined /* STRING */      

                };

                 

                Your JSON properties should be set on previous params content property, something like ( of course you must fill more parameters in order to make it work ):

                 

                var params = {

                  proxyScheme: undefined /* STRING */,

                  headers: undefined /* JSON */,            

                  ignoreSSLErrors: undefined /* BOOLEAN */,

                  useNTLM: undefined /* BOOLEAN */,

                  workstation: undefined /* STRING */,

                  useProxy: undefined /* BOOLEAN */,

                  withCookies: undefined /* BOOLEAN */,

                  proxyHost: undefined /* STRING */,

                  url: undefined /* STRING */,

                  content: {

                                Temperature: 10,

                                 Pression: 25,

                                 ThingName: "P1"

                               }

                   ,

                  timeout: undefined /* NUMBER */,

                  proxyPort: undefined /* INTEGER */,

                  password: undefined /* STRING */,      

                  domain: undefined /* STRING */,

                  username: undefined /* STRING */      

                };

            • Re: RestApi from ThingWorx to external Platform
              gfiore Newbie

              I try this , but the property not change on the other pc with Thinworxs installed.

              Where am I wrong? :-(

               

              var params = {

                proxyScheme: undefined /* STRING */,

                headers: undefined /* JSON */,

                ignoreSSLErrors: undefined /* BOOLEAN */,

                useNTLM: undefined /* BOOLEAN */,

                workstation: undefined /* STRING */,

                useProxy: undefined /* BOOLEAN */,

                withCookies: undefined /* BOOLEAN */,

                proxyHost: undefined /* STRING */,

                url:"http://xx.xx.xx.xx/ThingWorx/Things/P1/Properties" /* STRING */,

                content: {

                              NomePub: "Test",

                              Birra1: "Test",

                              ThingName: "P1"

                               }  /* JSON */,

                 

                password: "admin" /* STRING */,

                username: "Administrator" /* STRING */

              };

               

              // result: JSON

              var result = Resources["ContentLoaderFunctions"].PutJSON(params);

               

               

              On the monitoring of thingworx receiving is :

               

              [message: Invalid API Request: url [/Things/P1/Properties/] method [PUT]]



              Thnx

              Giuseppe