Skip to main content
1-Visitor
April 18, 2018
Solved

Consume REST API that needs token

  • April 18, 2018
  • 4 replies
  • 5252 views

Hi All,

 

I need to use a web service that needs authorization and consumes a token for it.
I know that I need to use some of the snippets function (ContentLoaderFunctions),
but I need someone to provide me some kind of example 'cause none of them has a field that uses my token.

 

Thanks,

Anselmo.

Best answer by Saitoisonfire

Looks like we cant use a webservice that consumes a token...

And that's the answer.

4 replies

22-Sapphire I
April 18, 2018

You will most likely need to declare that token through the header.

Something like "token:laksjdflksdajfladsjfjdsk"

1-Visitor
April 18, 2018

Something like this?

var token = {token:"abcdef"};
var params = {
headers: token /* JSON */,
ignoreSSLErrors: true /* BOOLEAN */,
url: "http://mymachine:8080/myapi" /* STRING */,
timeout: 30 /* NUMBER */,
};

 

Well, it didnt work out.

See the error mesage below:

Error executing service MyService. Message :: Connect to 192.168.229.139:8080 [/192.168.229.139] failed: connect timed out - See Script Error Log for more details.

1-Visitor
April 19, 2018

Nobody?

1-Visitor
April 20, 2018

Hello?

22-Sapphire I
April 20, 2018

When you tried that call what was the response? Check application log.

Can you list the actual documentation of the API call?

1-Visitor
April 23, 2018

The only response I received was this error mesage:
Error executing service MyService. Message :: Connect to 192.168.229.139:8080 [/192.168.229.139] failed: connect timed out - See Script Error Log for more details.

 

Documentation (my command is described in the page 26):
http://help.geautomation.com/Historian55/Subsystems/iHistGS/content/restapi.pdf

Saitoisonfire1-VisitorAuthorAnswer
1-Visitor
April 25, 2018

Looks like we cant use a webservice that consumes a token...

And that's the answer.