Catching the body of the error with sendJSONRequest

Posted by bakar on 18-Feb-2015 17:31

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

Posted by Godfrey Sorita on 19-Feb-2015 07:25

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

Posted by bakar on 19-Feb-2015 16:46

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?

Posted by Godfrey Sorita on 24-Feb-2015 15:18

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.

Posted by Godfrey Sorita on 24-Feb-2015 15:19

Can you send a link to the sandbox instance of your webservice so I can also test it on my end? Thanks!

Posted by bakar on 24-Feb-2015 15:26

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

Posted by Godfrey Sorita on 27-Feb-2015 10:09

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!

Posted by bakar on 27-Feb-2015 13:59

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

Posted by Godfrey Sorita on 27-Feb-2015 14:11

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

Posted by Godfrey Sorita on 05-Mar-2015 09:50

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.

This thread is closed