Hi
I am calling a web service then using DATA-INTO to receive the JSON to a DS.
When I call and get a "200 OK" message the JSON is returned without issue as the client was successfully updated on the server side.
The client can only be updated once...
When I call again with the same client details .... I get ... a "406 Not Acceptable" message and no JSON is returned!
Is this one for the programmers on the server side ?
Is there a reason the JSON does not get returned when the error occurs on the server side ?
monitor;
response = http_string('POST': url: request: 'application/json');
data-into resultDS %DATA(response:'case=any') %PARSER('YAJLINTO');
on-error;
httpCode = http_error();
apemsg = %trim(httpCode) + ' for ' + %trim(url);
exsr WriteErrorFile;
endmon;
Any input appreciated - I am a newbie to this stuff !
No JSON Returned if its not HTTP/1.1 200 OK
-
- Posts: 5
- Joined: Mon Mar 04, 2024 6:02 pm
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: No JSON Returned if its not HTTP/1.1 200 OK
I don't understand what you are asking.
Are you telling me that the "406 Not Acceptable" code should also return a JSON and you are not getting it?
Or are you saying that you want to receive a "200 OK" every time?
Are you telling me that the "406 Not Acceptable" code should also return a JSON and you are not getting it?
Or are you saying that you want to receive a "200 OK" every time?
-
- Posts: 5
- Joined: Mon Mar 04, 2024 6:02 pm
Re: No JSON Returned if its not HTTP/1.1 200 OK
When the HTTP Status is 200 ... the JSON response is received and is visible in my program ...
but when HTTP status is not 200 ... i.e 406 - Not Acceptable ... my DATA-INTO/response variable receive no JSON
but when HTTP status is not 200 ... i.e 406 - Not Acceptable ... my DATA-INTO/response variable receive no JSON
-
- Posts: 5
- Joined: Mon Mar 04, 2024 6:02 pm
Re: No JSON Returned if its not HTTP/1.1 200 OK
I noticed this on another post ...
"http_string() is meant as a way to make it easy to code -- but, it does make some assumptions that may not be right for you. One of its assumptions is that any response code aside from 200=Success means that it should send an *escape message."
Maybe I will have to use http_req() then
"http_string() is meant as a way to make it easy to code -- but, it does make some assumptions that may not be right for you. One of its assumptions is that any response code aside from 200=Success means that it should send an *escape message."
Maybe I will have to use http_req() then

-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: No JSON Returned if its not HTTP/1.1 200 OK
Yes, use http_req() if you need to get back the response variable when you get a code like 406.
-
- Posts: 5
- Joined: Mon Mar 04, 2024 6:02 pm
Re: No JSON Returned if its not HTTP/1.1 200 OK
Thanks for the that, Scott
I can get the 406 now ... I am more concerned about seeing the returned JSON.
As I said, when it is not 200 OK the JSON does not get returned !
Any help appreciated
I can get the 406 now ... I am more concerned about seeing the returned JSON.
As I said, when it is not 200 OK the JSON does not get returned !
Any help appreciated
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: No JSON Returned if its not HTTP/1.1 200 OK
I'm sorry, I don't understand where you are stuck. You've already discovered from another thread as well as my comments in this thread that you can get the response when you use http_req() instead of http_string(). What part isn't working for you? What is happening in your program?PragueBear wrote: ↑Tue Mar 26, 2024 9:52 am Thanks for the that, Scott
I can get the 406 now ... I am more concerned about seeing the returned JSON.
As I said, when it is not 200 OK the JSON does not get returned !
Any help appreciated
-
- Posts: 5
- Joined: Mon Mar 04, 2024 6:02 pm
Re: No JSON Returned if its not HTTP/1.1 200 OK
Hi Scott
Now using http_req() as advised. Looking good
Thank you for your help
Now using http_req() as advised. Looking good
Thank you for your help