5 Replies Latest reply on Nov 15, 2017 9:12 AM by cmorfin RSS
    jrajesh Newbie

    Thingworx Analytics 8.1 API Example

    Hi,

     

    I am trying to explore the Thingworx Analytics API - 8.1. I was trying to use the GetDatasetSchema service on the localhost-AnalyticsServer_DataThing as a REST API. Although there is API guide at ThingWorx Analytics API , an example will help me.

     

    Any documents giving example usages for the TWX Analytics API 8.1?

     

    Thanks and Regards,

    Jyothi

      • Re: Thingworx Analytics 8.1 API Example
        cmorfin Communicator

        Hi Jyothi

         

        You may want to have a look at this article: https://www.ptc.com/en/support/article?n=CS271485

        There are some explanation and most importantly, as far as example as concerned, you have a json collection file (at the very bottom) that you can download and import into, let's say Postman, to check some examples.

         

        Hope this helps.

         

        Kind regards

        Christophe

        • Re: Thingworx Analytics 8.1 API Example
          jrajesh Newbie

          Hi Christophe,

           

          Thanks you very much for getting back... that really helped!

          I am particularly trying to use the API

          http://127.0.0.1:8888/ThingWorx/Things/localhost-AnalyticsServer_DataThing/Services/GetDatasetSchema


          The documentation at ThingWorx Analytics API mentions the details. I am giving the body as follows, But I am still getting a 404. Any ideas what might be going wrong?

          {"dataSource": {

                          "dataShape": {

                              "fieldDefinitions": {

                                  "datasetUri": {

                                      "name": "datasetUri",

                                      "description": "Location of the data",

                                      "baseType": "STRING",

                                      "ordinal": 0,

                                      "aspects": {}

                                  },

                                  "format": {

                                      "name": "format",

                                      "description": "Structure of the data (CSV,PARQUET,CLQUET)",

                                      "baseType": "STRING",

                                      "ordinal": 0,

                                      "aspects": {}

                                  },

                                  "filter": {

                                      "name": "filter",

                                      "description": "SQL WHERE clause to refine the dataset",

                                      "baseType": "STRING",

                                      "ordinal": 0,

                                      "aspects": {}

                                  },

                                  "exclusions": {

                                      "name": "exclusions",

                                      "description": "Fields to remove from the dataset",

                                      "baseType": "INFOTABLE",

                                      "ordinal": 0,

                                      "aspects": {

                                          "dataShape": "GenericStringList"

                                      }

                                  },

                                  "data": {

                                      "name": "data",

                                      "description": "An infotable of data (must be flat. for providing data as part of request)",

                                      "baseType": "INFOTABLE",

                                      "ordinal": 0,

                                      "aspects": {}

                                  },

                                  "metadata": {

                                      "name": "metadata",

                                      "description": "Metadata of the dataset (for providing data as part of request)",

                                      "baseType": "INFOTABLE",

                                      "ordinal": 0,

                                      "aspects": {

                                          "dataShape": "AnalyticsDatasetMetadata"

                                      }

                                  }

                              }

                          },

                          "rows": [

                              {

                                  "datasetUri": "dataset:/1715c6d4-a513-44fa-be49-68fcd1075642",

                                   "format": "parquet"

                              }

                          ]

                      }

          }

           

          Thanks and Regards,

          Jyothi

            • Re: Thingworx Analytics 8.1 API Example
              cmorfin Communicator

              Hi Jyothi

               

              I have used your code and it works for me.

              Since you are gettign a 404 error this woudl indicate that the URI has some error.

              Are you sure of the Thing name in the URI ?

               

              Thanks

              Christophe

                • Re: Thingworx Analytics 8.1 API Example
                  jrajesh Newbie

                  Hi Christophe,

                   

                  The Thing name is correct. I could execute the ListCreatedDatasets API with this thing. Is there a way to access the http access logs to understand what is the REST URI that reached the server? I can compare mine with the one executed via Thingworx Test Services. The same service executed via ThingWorx works fine.

                   

                  Thanks and Regards,

                  Jyothi

                    • Re: Thingworx Analytics 8.1 API Example
                      cmorfin Communicator

                      Hi Jyothi

                       

                      You can get the access.log (and error.log) with the command: docker cp nginx:/var/log/nginx .

                      This will copy the /var/log/nginx folder to the local path, change . with the full path to the local directory if you want it somewhere else.

                       

                      hope this helps.

                      Kind regards

                      Christophe