Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
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.
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
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.vehicleRegNo,
eventTypeName:data.array.eventTypeName,
eventLocDescription:data.array.eventLocDescription,
eventDatetime:data.array.eventDatetime,
speed:data.array.speed,
description:data.array.description
});
}
Prabhat Mishra : I suspect the machine name in the error does not exist in the host files or need to troubleshoot more on hostname resolution.
C:\Windows\System32\Drivers\etc\hosts
There is no issue in service code and issue seems to be occurring during hostname resolution. Unfortunately resolving host names issue can be caused due to many factors.
You could also try telnet'ing to the IP/DOMAIN and port to see if it will accept a connection. Alternatively if there is a routing problem from your location, you should try and run a traceroute to both the direct IP and the hostname.
It could also be worth doing a DNS lookup ( nslookup) for the domain which you are trying to connect to, if the DNS entry doesn't match the direct IP you have, then there could be a problem where you are reading a corrupt record maybe?
Try connecting to the IP address that the lookup says it resolves to.
-Durgesh
Thanks Durgesh for all necessary information.
But same rest API , i am able to call in postman and i am also be available to fetch in swaager.
Do you get the same error message every time when you run this service or does multiple retries run randomly ?
I am getting dam error message every time. When I call in thing service