Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Parikhharshal
Creator III
Creator III

tRest_Client Error handling

Hi experts

 

I have built the job for Rest API URL and I am using tRest_Client to read off my API url.

 

However, when it cannot find Next URL then it just throws 404 HTTP not found. Is there any way I can handle these errors properly?

 

0683p000009M10K.png

 

Thanks

Harshal.

Labels (4)
6 Replies
root
Creator II
Creator II

Feels like you are probably calling an incorrect url in trestclient.


Is the NEXT url a part of the response? If yes, Could you share how you are parsing the response?

Thnx.
Parikhharshal
Creator III
Creator III
Author

@mbocquet: Thanks for your quick reply.

 

Written a java code which keeps moving to next URL until it finds one. And for a test I am just printing that message on the screen. 

 

What I cannot digest is for particular course IDs when it cannot find next url then it shows 404 http error for not for all.

root
Creator II
Creator II

Tbh, its difficult to figure out what you are trying to achieve... what does the java code do and how is it connected with trestclient
root
Creator II
Creator II

@Parikhharshal:

There are two outputs you can get from a tRestClient (Response and Error). You may want to keep checks at both outputs and check for the HTTP status code being returned. If you get a 200, it would mean that the request was successful. If the HTTP status was 404, it means that is the incorrect URL.

It beats me, why you would need to hit all random urls to fetch the correct NEXT url. A correctly designed rest service would typically send the next url info.

HTH
Parikhharshal
Creator III
Creator III
Author

@mbocquet: Yes you are right. I ended up cleaning up crappy data and that created correct URL for me in the result.

 

Thanks for your response.

anna_t1
Contributor III
Contributor III

@Shicong Hong​ , @Xiaodi Shi​ , still on this topic:

I'm catching both response and error messages from API request. But what about Java exceptions from the API, like socket timeout exception? Let's say that I got a read time out, which is a java exception, how can I caught this in the job (I know tlogcather does that) and do something after it, let'say: repeat the request or sleep some seconds?