on 2020 May 05 5:30 AM
I am consuming external webservices from my SQL-Anywhere 17 and I am interested in the HTTPSTATUS of the response more than the body itself, so I want just to check if the call to the webservice has succeeded (i.e. whether I got 200 OK as HTTP Status)!
I tried to write something like this, but I get always an empty string in my @ResponseStatus variable!
create or replace function UpdateAPI(EndPoint varchar(200), UserName varchar(200), PWD varchar(200), PayLoad long varchar)
returns long varchar
url 'http://!UserName:!PWD@!EndPoint'
type 'http:put:application/json';
begin
declare @ResponseBody long varchar;
declare @ResponseStatus long varchar;
set @ResponseBody = WC_UpdateAPI(@Endpoint, @username, @pwd, @PayLoad);
set @ResponseStatus = HTTP_RESPONSE_HEADER('@HttpStatus'); select @ResponseBody, @ResponseStatus;end;
On the other side, I can see this HTTP Response in the WebClientLogFile (as HTTP/1.0 200 OK).
Could please somebody tell me Where I am doing mistake?
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One more question, how can I then get both "body" and "Status" using one single call?
In the mentioned example how can I merge those both calls in one call:
SELECT "value" FROM SAPWebPage() WITH (Attribute LONG VARCHAR, Value LONG VARCHAR, Instance INT) WHERE Attribute = 'Status';
SELECT "value" FROM SAPWebPage() WITH (Attribute LONG VARCHAR, Value LONG VARCHAR, Instance INT) WHERE Attribute = 'body';
You mean, get those values
For the 1. you can use a PIVOT clause:
SELECT "'Status'" AS STATUS, "'Body'" AS Body FROM (SELECT "attribute", "value" FROM SAPWebPage() WITH (Attribute LONG VARCHAR, Value LONG VARCHAR, Instance INT)) ST PIVOT (min("value") FOR "attribute" in ('Status', 'Body')) PT
For the second, you would obviously just do something like:
SELECT "attribute", "value" FROM SAPWebPage() WITH (Attribute LONG VARCHAR, Value LONG VARCHAR, Instance INT) WHERE "attribute" in ('Status', 'Body')
User | Count |
---|---|
60 | |
10 | |
8 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.