ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportStatusCode not changing in REST API

Post new topicReply to topic
StatusCode not changing in REST API View previous topic :: View next topic
Author Message
urufberg
PostPosted: Sun Aug 18, 2019 7:30 pm Post subject: StatusCode not changing in REST API Reply with quote

Apprentice

Joined: 08 Sep 2017
Posts: 25

Hi,

I'm developing an API POST method using a mapping node. My problem is that when I try to override the REST>Response>StatusCode in the Local Environment, this code is not passed in the response and instead I get a 200 OK as a response in Postman.

The code I'm passing is defined in the swagger, so If I understand correctly, it should take the StatusCode I'm setting so, what am I missing?

For context:
IIB v10 fix 17

Thanks in advance!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 19, 2019 4:28 am Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20119
Location: LI,NY

AFAIK there is no environmental override for the status code. It needs to be set on the HTTP Header...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
abhi_thri
PostPosted: Mon Aug 19, 2019 4:42 am Post subject: Reply with quote

Partisan

Joined: 17 Jul 2017
Posts: 321
Location: UK

hi...as mentioned in the previous post the Statuscode cannot be overridden as that is something returned in the response and not in the request. Also why would you want to override it in the first place? the below topic explains which params can be overridden when dealing with REST nodes,

https://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/bz90950_.htm
Back to top
View user's profile Send private message
urufberg
PostPosted: Mon Aug 19, 2019 6:11 am Post subject: Reply with quote

Apprentice

Joined: 08 Sep 2017
Posts: 25

Thank you for your responses @fjb_saper and @abhi_thri.
abhi_thri wrote:
as mentioned in the previous post the Statuscode cannot be overridden as that is something returned in the response and not in the request.

I'm failing to understand then why you can define the REST API responses and statuts code (is it just for documentation?).

abhi_thri wrote:
https://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/bz90950_.htm


In this document, the following Local Environment variable is defined:
Quote:
LocalEnvironment.WrittenDestination.REST.StatusCode integer: The HTTP status code in the response from the REST API.


What i'm looking for is to return an standard error code if certain conditions are met.

Maybe a more general question would be, how do you guys usually go about implementing error responses in your IIB REST APIs?

Thank you,
Back to top
View user's profile Send private message
abhi_thri
PostPosted: Mon Aug 19, 2019 7:34 am Post subject: Reply with quote

Partisan

Joined: 17 Jul 2017
Posts: 321
Location: UK

urufberg wrote:

I'm failing to understand then why you can define the REST API responses and statuts code (is it just for documentation?).

In this document, the following Local Environment variable is defined:
Quote:
LocalEnvironment.WrittenDestination.REST.StatusCode integer: The HTTP status code in the response from the REST API.




hi...anything that comes at "WrittenDestination" cannot be overridden, it is just available for inspection. i.e you can only override the Request parms and not the results returned from the Web call which are logged at "WrittenDestination". You can indeed inspect these values and then decide on how to progress further
Back to top
View user's profile Send private message
timber
PostPosted: Mon Aug 19, 2019 7:43 am Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1038

Should be possible to specify the HTTP status code that your message flow sends: https://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ac20450_.htm

Quote:
Setting the HTTP Status Code for a reply
The default HTTP Status Code is 200, which indicates success. If you want a different status code to be returned, take one of the following actions:

* Set your status code in the field Destination.HTTP.ReplyStatusCode in the local environment tree (correlation name OutputLocalEnvironment). This field overrides any status code that is set in an HTTPResponseHeader header. This action is the preferred option, because it provides the greatest flexibility.
* Set your status code in the field X-Original-HTTP-Status-Code in the HTTPReplyHeader header.
* Set your status code in the field X-Original-HTTP-Status-Code in the HTTPResponseHeader header. This option is useful if you include an HTTPRequest node before the HTTPReply node in your flow, because the HTTPResponseHeader header is created for you. In this scenario, an HTTPResponseHeader header has been created in the logical tree, representing the HTTP headers in the response from another web service. If you have selected the Generate default HTTP headers from reply or response property on the HTTPReply node, values for the response header are set as default values when the reply message is created.
Back to top
View user's profile Send private message
urufberg
PostPosted: Mon Aug 19, 2019 8:37 am Post subject: Reply with quote

Apprentice

Joined: 08 Sep 2017
Posts: 25

abhi_thri wrote:
hi...anything that comes at "WrittenDestination" cannot be overridden, it is just available for inspection. i.e you can only override the Request parms and not the results returned from the Web call which are logged at "WrittenDestination". You can indeed inspect these values and then decide on how to progress further


Thank you. Im guessing that the LocalEnvironment>REST>Response>StatusCode parameter is also intended to be inspected and not changed based on timbers response

timber wrote:
Should be possible to specify the HTTP status code that your message flow sends: https://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ac20450_.htm

Quote:
Setting the HTTP Status Code for a reply
The default HTTP Status Code is 200, which indicates success. If you want a different status code to be returned, take one of the following actions:

* Set your status code in the field Destination.HTTP.ReplyStatusCode in the local environment tree (correlation name OutputLocalEnvironment). This field overrides any status code that is set in an HTTPResponseHeader header. This action is the preferred option, because it provides the greatest flexibility.
* Set your status code in the field X-Original-HTTP-Status-Code in the HTTPReplyHeader header.
* Set your status code in the field X-Original-HTTP-Status-Code in the HTTPResponseHeader header. This option is useful if you include an HTTPRequest node before the HTTPReply node in your flow, because the HTTPResponseHeader header is created for you. In this scenario, an HTTPResponseHeader header has been created in the logical tree, representing the HTTP headers in the response from another web service. If you have selected the Generate default HTTP headers from reply or response property on the HTTPReply node, values for the response header are set as default values when the reply message is created.



Thanks! I don't know why I have the idea that there was a specific functionality built int for REST flows.

I still wonder:
fbergeret wrote:
how do you guys usually go about implementing error responses in your IIB REST APIs?


Regards
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportStatusCode not changing in REST API
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.