Catching the body of the error with sendJSONRequest - Forum - Rollbase - Progress Community

Catching the body of the error with sendJSONRequest

 Forum

Catching the body of the error with sendJSONRequest

This question is not answered

Hi,

Normally the webservice sends an error message back. I can only catch the header. See example below the body of the error json message:

Now i have another example with a 500 Internal Server Error. This occurs during the execution of the request. Most of the time these are validation errors. The body of the response contains the error information, for example:

{
"error": {
"code": "",
"message": {
"lang": "",
"value": "Can't delete: Account 58 - Used in: Administrations"
}
}
}

How can i catch the body of the error message? When working with the sendJSONRequest, I only get the header, see below the screenshots:

This is the part of the object script trigger:

And from the debug window:

I have tried error.message.value and also e.error.message.value, but it looks like that I can not catch these information. Is that true?

All Replies
  • Hi Resul,

    You should be able to get the value of the error using resp.error.message.value. Can you check this on your end?

    This specific response is not parsed to JSON format correctly because of the single quote which breaks the string.


    Regards,
    Godfrey
  • Hi Godfrey,

    I had tried that before: resp.error.message.value

    The resp variable keeps empty. The following error message pops up:

    Cannot Read Property "error" From Undefined (line #49)

    Any more idea's?

  • Please try using "Send HTTP GET Request" trigger. This type of trigger retrieves the response and stores the 2 values ("ReturnStatus" and "ReturnBody"). These values can be accessed from an object script right after the trigger using rbv_api.getSharedValue().

    Let me know how it goes.
  • Can you send a link to the sandbox instance of your webservice so I can also test it on my end? Thanks!
  • Hi Godfrey,

    Can we arrange a web session? Its a bit complex with the oAuth2 authorization. The tokens are only valid for 10 minutes. Can you send me your mail address? You can reach me at: resul@brixxs.com

    TIA

  • I was able to confirm that Rollbase cannot retrieve response codes other than OK(code 200). This was tested using PayPal rather than Exact Online though.

    For now, kindly post your enhancement request on the ideas section(https://community.progress.com/community_groups/products_enhancements/i/rollbase/default.aspx). Thanks!
  • Hi Godfrey,

    As I said earlier this is really a biiiig shortcoming (bug). It's totally not usable if we can't do the error handling. The webservice does not give only response codes between 200 and 210; it should throw an error when dealing with other response codes and manage the errors correctly.

    The native http GET/POST trigger works correctly but we can not use dynamic URL's in it. When using Odata, it's common to use dynamic queries in the URL. Also here, it's import to handle the errors correctly.

    Could you please discuss this with the team again?

    Regards, Resul

  • Yes, I will discuss this with the internal teams and let you know how it goes.

  • I discussed this with development and the issue still remains as an enhancement. They are planning to update the libraries needed for this enhancement on release 4.0.