6 Replies Latest reply on Sep 1, 2017 5:33 AM by pmishra-4 RSS
    pmishra-4 Explorer

    Problem in calling rest API in thing Service

    Hi,

     

    I am not able to call rest API from thing service deployed on cloud  and its giving error. While on trying in postman , it's working fine. Is there any setting required for thing.

      • Re: Problem in calling rest API in thing Service
        dupatel Creator

        Prabhat Mishra : Could you please share how you are making REST call via service and what exactly is the error message you are getting while running the Service?

         

        -Durgesh

          • Re: Problem in calling rest API in thing Service
            pmishra-4 Explorer

            Hi,

             

            Its working fine with local host URL. But  showing error for below URL

            url:"http://dev1.tcupiot.com/app/user5/TTSLService/Alert/Query?eventDateTime=YYYY-MM-dd" /* STRING */,

            Error is:

            Wrapped java.net.UnknownHostException: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server (dev1.tcupiot.com) Cause: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server (dev1.tcupiot.com)

             

             

            I am trying this code .



            var params1 = {

            proxyScheme: undefined /* STRING */,

            headers:{

              "Accept": "*/*",

              "tenantId": "12345"

            },

            ignoreSSLErrors: undefined /* BOOLEAN */,

            useNTLM: undefined /* BOOLEAN */,

            workstation: undefined /* STRING */,

            useProxy: undefined /* BOOLEAN */,

            withCookies: undefined /* BOOLEAN */,

                url:"http://dev1.tcupiot.com/app/user5/TTSLService/Alert/Query?eventDateTime=YYYY-MM-dd" /* STRING */,

                //url:"http://localhost:8081/TTSLFleetWeb/Alert/Query?eventDateTime=2016-06-12%2C2018-10-15",

                timeout: undefined /* NUMBER */,

            proxyPort: undefined /* INTEGER */,

            password: undefined /* STRING */,

            username: undefined /* STRING */

            };

             

             

            // result: JSON

            var data = Resources["ContentLoaderFunctions"].GetJSON(params1);

             

             

            var params2 = {

            infoTableName: "alertTable" /* STRING */,

            dataShapeName: "AlertDataShape" /* DATASHAPENAME */

            };

            var jsonTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params2);

            for(var i=0;i<data.array.length;i++)

            {

             

            jsonTable.AddRow({vehicleRegNo:data.array[i].vehicleRegNo,

                              eventTypeName:data.array[i].eventTypeName,

                              eventLocDescription:data.array[i].eventLocDescription,

                            eventDatetime:data.array[i].eventDatetime,

                              speed:data.array[i].speed,

                              description:data.array[i].description

                            });

             

            }