Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Hi All,

I have Googled and Googled, (as well as search the forum), and I can't find a definitve answer so hoping someone can help. If this stops the question in its tracks this is SQL Anywhere!

We have a customer using Web Services in SQL Anywhere which works fine with GET but they would like to POST the data using a JSON payload. The response type of the Web Service is set to JSON and the documentation I have found indicated that POST is setup by default with RAW, XML, JSON, etc. as available datatypes.

I can't find an example of any JSON that can/should be posted which may tell me it isn't possible but hoping someone can confirm if we can post JSON to the web service or if there is something that needs turning on.

The web service is:

CREATE SERVICE "WAddCustomer" URL PATH OFF TYPE 'JSON' USER "webuser" AS call "spaceman"."WAddCustomer"("idoreturn" = "HTTP_VARIABLE"('idoreturn'),"isite" = "HTTP_VARIABLE"('isite'), "isurname" = "HTTP_VARIABLE"('isurname'));

Calling the target:



{ "idoreturn":"1" "isite":"RI0XTEJM071220170001" "isurname":"Squires" }

I have tried putting this all into an ARRAY as well as the return is all in an ARRAY, (see below), and wondered if that was the format SQL Anywhere required.

I always get the return that

[ { "customerid":"INVALID" }]

The return is coming from the function and in debug I can certainly see no data is being received by it hence the "INVALID return.

Is this possible or does the data have to be posted data pairs or similar?



asked 05 Jan '23, 07:09

RADicalSYS's gravatar image

accept rate: 9%

{ "idoreturn":"1" "isite":"RI0XTEJM071220170001" "isurname":"Squires" }

FWIW, that's no valid JSON string, members of an object have to be separated via commas, see here for reference.

That being said, the docs on CREATE SERVICE do tell:

The database server does not parse the JSON input automatically. It is up to the application to parse it.

So I would assume that it won't work to use

idoreturn" = "HTTP_VARIABLE"('idoreturn')...
when calling the procedure. I would assume you need to call the procedure with the whole body as variable and within the procedure (probaby via the builtin sp_parse_json() procedure) separate the elements of the JSON object.

permanent link

answered 05 Jan '23, 07:28

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

converted 05 Jan '23, 07:38

Sorry about the JSON - I couldn't copy and paste from the other PC so typed all this in and, as pointed out I missed the commas. Doh.

I did see it mentioned about not parsing the JSON but I think from Volker's answer I understand rather more what that means now, (or rather that it means it's a PITA to do).

Will see what the client says about posting the data just as key-value pairs - it's not very different to the JSON anyway in the basic way it needs sent!

Thanks for the input.

(05 Jan '23, 08:32) RADicalSYS
Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 05 Jan '23, 07:09

question was seen: 709 times

last updated: 05 Jan '23, 08:32