
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tRESTClient Error Handling
I'm calling the FedEx Rates and Transit Times API to get FedEx Ground Service quotes using the tRESTClient component. Out of 2000 rows of input, 5 result in error returns from the API. For error handling, I'm starting off simple and using tLogRow to output the contents of the Error row coming out of the tRESTClient
I get the following from the tLogRow component when the input results in an error from the API
If I submit the test input to the API using Postman, I get a 400 Bad Request HTTP Response and the following is in the API response body:
{
"transactionId": "d285fa18-8b24-49c8-9b35-1085a0092b01",
"customerTransactionId": "771554139682",
"errors": [
{
"code": "RATE.LOCATION.NOSERVICE",
"message": "FedEx service is not currently available to this origin / destination combination. Enter new information or contact FedEx Customer Service."
}
]
}
How should I be handling the Error row that gets emitted by tRESTClient, specifically the ErrorMessage field? How do I access the JSON response body returned from the API in error handling?
By default, Talend Studio sets up the Error row with integer type for the errorCode field, and String for the errorMessage field.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It turns out that the implementation of tRESTClient is kinda half-baked.
If the API call succeeds (HTTP 200 Ok) and the response body returned by the server is gzip compressed, tRESTClient will gzip decode/decompress the response body and return it in the string field of the Response flow.
If the API call returns an error (anything besides an HTTP 200 Ok response0 and the response body returned by the server is gzip compressed, the errorMessage field of the Error flow gets populated with the raw gzipped response body (WHAT?!)
The solution is to use tHTTPClient instead, which appears to be 1) a new component in Talend Studio 8.0; 2) not installed by default, so you have to install it via the Studio Feature Manager.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Link the error data flow to a tExtractJsonFields component and extract the messages from the errorMessage field. Please refer to the component documentation and learn tExtractJsonFields component.
Regards
Shong

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll give that a shot.
I have used the tExtractJSONFields component for the API Response output side of the tRESTClient. When I connect the Response to a tLogRow, I see plain text unparsed JSON, not the sort of binary gibberish I'm seeing in the errorMessage field of the Error output from the tRESTClient that I'm seeing in the above tLogRow screenshot.
EDIT:
Tried connecting the tExtractJSONFields component to the Error output of the tRESTClient. Extracted assuming the errorMessage contains what I'm seeing in Postman as the JSON body returned by the API call error. The fields I extract out based on that assumption are empty. In fact, I developed the Response handling side of the tRESTClient by first connecting that to a tLogRow to verify the JSON schema that I was expecting to parse. I can't do the same thing on the Error output from tRESTClient because the errorMessage field is gibberish.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It turns out that the implementation of tRESTClient is kinda half-baked.
If the API call succeeds (HTTP 200 Ok) and the response body returned by the server is gzip compressed, tRESTClient will gzip decode/decompress the response body and return it in the string field of the Response flow.
If the API call returns an error (anything besides an HTTP 200 Ok response0 and the response body returned by the server is gzip compressed, the errorMessage field of the Error flow gets populated with the raw gzipped response body (WHAT?!)
The solution is to use tHTTPClient instead, which appears to be 1) a new component in Talend Studio 8.0; 2) not installed by default, so you have to install it via the Studio Feature Manager.
