cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Call external Rest API from thingworx application

cbaurand
12-Amethyst

Call external Rest API from thingworx application

Hi,

 

I need to call a REST API from my thingworx application. To achieve that, i try to use the ContentLoaderFunctions resources.

1- Is it the right way ?

2- If yes, i try to call a test Rest API, but it doens't work:

 

var result = Resources["ContentLoaderFunctions"].GetJSON({
	url: "https://jsonplaceholder.typicode.com/todos/1" /* STRING */,
	timeout: 30000 /* NUMBER */,
    headers:undefined,
	ignoreSSLErrors: false /* BOOLEAN */,
	useProxy: false /* BOOLEAN */,
	proxyHost: undefined /* STRING */,
	proxyPort: undefined /* INTEGER */,
	proxyScheme: undefined /* STRING */
});

 

or

 

var result = Resources["ContentLoaderFunctions"].GetJSON({
	url: "https://jsonplaceholder.typicode.com/todos/1" /* STRING */,
	timeout: 30000 /* NUMBER */,
    headers: {'Host': 'jsonplaceholder.typicode.com', 'Accept':'application/json', 'Content-Type':'application/json'},
	ignoreSSLErrors: false /* BOOLEAN */,
	useProxy: false /* BOOLEAN */,
	proxyHost: undefined /* STRING */,
	proxyPort: undefined /* INTEGER */,
	proxyScheme: undefined /* STRING */
});

 

 

In both cas, i receive

" Error executing service testRTestApiCall. Message :: Received fatal alert: handshake_failure"

 

Any idea ?

 

Thanks for your help.

 

 

2 REPLIES 2
yhan
17-Peridot
(To:cbaurand)

Did you use a self-signed certificate for "jsonplaceholder.typicode.com"? Is the SSL port 443? How about set "ignoreSSLErrors = true" in the params?

cbaurand
12-Amethyst
(To:yhan)

Thanks for your response.

"jsonplaceholder.typicode.com" is a well known test site you can use for testing api Call. I can call it with postman and it works. Changing "ignoreSSLErrors " to false or true doesn't change anything.

But, i have 2 instances of my Thingworx application:

one running on my local pc, inside docker container. This one leads to the issue.

one running on PTC server. This one works fine. So, it seems there is a problem with my docker image. I need to investigate but any idea would be appreciate.

Thanks.

Announcements


Top Tags