Hello All,
I am developing a small test application using Netweaver Gateway to understand the error handling. I am using Postman to test the Gateway service. I have developed small RFC FM to read return list of deliveries for a shipment. The RFC reads in a shipment number and returns the list of deliveries. The RFC also has Return parameter of type BAPIRET2 that stores the error message if shipment is not found. We want to use only JSON format for the application. So, I have set the 'Accept' parameter at request header to 'content/json'. I am also aware of the exception /IWBEP/CX_MGW_BUSI_EXCEPTION that allows to throw an error message from backend suite. I have that by having a Return parameter of type BAPIRET2, the generated method automatically handles the error message and sets the correct HTTP status.
Now the Problem:
As mentioned earlier, we want to use JSON format. When I set the header parameter or specify $format=json in the URI the HTTP status code is always set to 500 when there is an error. The error message about invalid shipment also is not returned.
When I remove the JSON format parameters, the XML format is returned and HTTP status is set to 400 with appropriate error message.
How can we get the Gateway to set the HTTP status code to 400 along with error message in the event of an error in RFC. I have tried with the exception /IWBEP/CX_MGW_BUSI_EXCEPTION and BAPIRET2 return parameter but still does not work. Is this a known issue in Gateway/JSON?
Please see attached screenshots.
Thanks,
Rutul Thakkar