cancel
Showing results for 
Search instead for 
Did you mean: 

POST with bearer token gives error but processes ok

fvestjens
Participant
588

SQL Anywhere 17 build 6933

We're calling an external webservice from within the database to send data to an external web application. We are using the below procedure to establish this:

create or replace procedure ShuntPlan_API_PostLinkEquipment(in inBaseurl long varchar
                                                           ,in inJson long varchar
                                                           ,in inToken long varchar) 
url '!inBaseurl/equipment/link?api-version=2'
type 'HTTP:POST:application/json'
set 'HTTP(VERSION=1.1;EXCEPTIONS=OFF)'
header 'Accept: application/json \
Authorization: !inToken'

We call this procedure in the database using:

select * 
from usr.ShuntPlan_API_PostLinkEquipment('https://...','{....}','bearer 9874....')
with (Attribute long varchar, "Value" long varchar, Instance integer)
When running the statement in I-SQL it randomly returns HTTP/1.1 200 OK or the below error.
There was an error reading the results of the SQL statement.
The displayed results may be incorrect or incomplete.
The secure connection to the remote host failed: The connection was
closed from the other side
SQLCODE=-990, ODBC 3 State="HY000"
Line 2, column 1
When running from the database we log the result in a table. There the same error is saved only in a slightly different format.

However when we enable HTTP output logging, all the requests show the same result even when we get the error:

[connid = 23, [21/09/2023:12:32:09.694 0200], RESPONSE]
HTTP/1.1 200 OK
Date: Thu, 21 Sep 2023 10:32:09 GMT
Content-Length: 0
Connection: close
Strict-Transport-Security: max-age=15724800; includeSubDomains
[connid = 23, socket closed]

What might be causing this and is there a way to prevent this from happening?

Accepted Solutions (0)

Answers (1)

Answers (1)

PCollins
Explorer
0 Kudos

Hi,

Try setting the header "Connection:keep-alive"

Other anomalies I came across are listed here:

https://sqlanywhere-forum.sap.com/questions/38649/our-experiences-using-sqla-https-webclient