How can I consume a rest webservices that uses a Token as authorization?

I created this function: ALTER FUNCTION "dba"."fn_AFAS_subscriptions"( ) returns long nvarchar url 'https://12345.rest.afas.online/ProfitRestServices/connectors/Profit_Subscriptions' type 'HTTP:GET' header 'Authorization: AfasToken PH..<base64 encoded="" string="">..uPg=='

When I call this function I get: Could not execute statement. The secure connection to the remote host failed: The connection was closed from the other side SQLCODE=-990, ODBC 3 State="HY000" Line 1, column 1 call "dba"."fn_AFAS_subscriptions"()

I tried also toe replace AfasToken to Bearer. Did not help also.

Is this a problem of authorization or TLS versions or ...?

The url work fine when I executed it with a online rest client test tool in the browser. So the token and url are correct.

Using SA17,0,10 build 6230.

Tia Hans

asked 27 Oct '21, 09:37

HansTSD's gravatar image

HansTSD
220131521
accept rate: 20%

1

Have you checked via web client logging via

CALL sa_server_option( 'WebClientLogging', 'ON' )

or dbsrv17 -zoc <logfile> whether the request looks correct?


See also this FAQ...

(27 Oct '21, 10:23) Volker Barth

Thanks Volker.

With WebClientLogging I got this output:

[connid = 140, [30/10/2021:12:29:03.815 0200]] [connid = 140, [30/10/2021:12:29:03.815 0200], REQUEST] GET /ProfitRestServices/connectors/Profit_Subscriptions HTTP/1.0 Date: Sat, 30 Oct 2021 10:29:03 GMT Host: 12345.rest.afas.online Connection: close ASA-Id: 2ca4f......e202 Accept-Charset: UTF-8, * User-Agent: SQLAnywhere Authorization: AfasToken PHRxxxg.....==

[connid = 140, Error: socket closed by peer] [connid = 140, socket closed]

Another try with HTTP version set to 1.1: [connid = 140, [30/10/2021:12:57:50.043 0200], REQUEST] GET /ProfitRestServices/connectors/Profit_Subscriptions HTTP/1.1 Host: 12345.rest.afas.online Accept-Charset: UTF-8, * User-Agent: SQLAnywhere Authorization: AfasToken PHR....uPg== ASA-Id: 2ca4f...e202 Date: Sat, 30 Oct 2021 10:57:50 GMT Connection: close

[connid = 140, Error: socket closed by peer] [connid = 140, socket closed]

I created a C# Core application that could connect without problems. From the same PC as the database is running.

(30 Oct '21, 06:57) HansTSD
Replies hidden

My idea was to use web clientogging to check whether the request sent by SQL Anywhere is similar to that of your test tool, particularly the treatment of the token. Can you confirm that?

Addionnally, you are using HTTPS in your original post, so does SQL Anywhere have access to the web server's root certificate?

(30 Oct '21, 11:00) Volker Barth
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×64

question asked: 27 Oct '21, 09:37

question was seen: 724 times

last updated: 30 Oct '21, 11:01