I want to call an external API using an internal function in SQL-Anywhere 17: create or replace function TokenRequest ("JsonPayLoad" long varchar) returns long varchar url 'http://localhost/api/token' Header 'Content-Type: application/json'; The JsonPayLoad looks like: { "grant-type": "client-credentials", "scopes": "read" } When I call this API using CURL (under windows) I should add \ as escape sequence, so the call on CURL looks like this (it works): curl -X POST "http://localhost/api/token" --header "Content-Type: application/json" --data "{\"grant-type\": \"client-credentials\",\"scopes\": \"read\"}" My question how should I pass the JsonPayload to my TokenRequest function? This one for example brings an Status=400; Bad Request: call TokenRequest('"{"grant-type": "client-credentials","scopes": "read"}') |
@Sako asked:
It's using SOAP because the docs say so :)
and your create function statement does not use a TYPE clause. (I have not used JSON with web client functions/procedures so I can't help on the other issues.) 1
Oh, sorry! After changing TYPE clause into: type 'http:post:application/json' Then the second problem is also solved! Thank you
(03 Apr '20, 03:56)
Baron
Replies hidden
So the full question is solved?
(03 Apr '20, 04:04)
Volker Barth
Yes, but I can't convert your comment to answer :(
(03 Apr '20, 04:05)
Baron
|
Above I replaced each quot with qot, in order to prevent the escape sequence
My question is, why the body is sent as SOAP and XML, and why all quotation marks are replaced with & q u o t ; (without spaces)