HI Stephen

I followed The Nadir's link for normal web services deployment
https://developer.ibm.com/tutorials/i-rest-web-services-server3/

So if you set the http header like

if (%ERROR);
httpStatus = H_SERVERERROR;
return;
endif;

It should work perfectly fine. I got it working for all of the below status
codes.

D H_OK c const(200)
D H_CREATED c const(201)
D H_NOCONTENT c const(204)
D H_BADREQUEST c const(400)
D H_NOTFOUND c const(404)
D H_CONFLICT c const(409)
D H_GONE c const(410)
D H_SERVERERROR c const(500)

This is my suggestion as It worked for me :)

Thanks
Anshul




On Mon, Jun 24, 2019 at 5:32 PM Stephen Piland <
Stephen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

For more info, see thread below in link..

I have a POST created in IWS that has a struct (JSON) as an Input
parameter. It also uses httpStatus, and httpHeaders. We also return 2
character messages. When everything is goes well, we return 200 and in the
'body' that is returned, we receive the contents of successMessage and
errorMessage in JSON formats.

We've tried to add validation on say items and locations in the Order
(JSON) struct before actually doing anything in the code. I was thinking
we could set the httpStatus to 4xx, set errorMessage to some string, and
IWS would return the errorMessage just like if 2xx. We don't seem to get
anything back in the response.

Any thoughts? Thanks.


=======================================================================================

Procedure Interface...
Dcl-pi createOrder;
Order likeds(orderInfo);
httpStatus int(10);
httpHeaders char(100) dim(10);
successMessage char(100);
errorMessage char(100);
End-pi;


https://stackoverflow.com/questions/942951/rest-api-error-return-good-practices?noredirect=1&lq=1


--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.