Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Getting 400 Bad request Error in trest client component

Hi,

When I was calling a http service using oauth Bearer token method of trestclient I am getting 400 service error but for the same url in postman I was able to retrieve the expected output.

How can I troubleshoot this issue or is there any other component apart from trestclient we can use for this.

 

Labels (3)
9 Replies
Sujay1
Creator
Creator

@baladevi  can you post screenshots of how ur calling.

Anonymous
Not applicable
Author

Hi @Sujay 

Please find the attached screenshot.

 


Trest_Advance.PNG
Trest_main.PNG
Sujay1
Creator
Creator

@baladevi  i was not having any API to test so i used postman API itself for testing the Authorization part.Try like below and let me know if it works.

 

0683p000009M7JV.png0683p000009M7Gn.png0683p000009M7Jf.png

 

Let me know how it goes. happy to help 0683p000009MACn.png

Anonymous
Not applicable
Author

Hi,
I tried in that way as well but I was getting the same error. Is there a way where we can get what request is been generated and sent. The same http url when I tried in thttprequest component it gave me a successful response but I want to retrieve the response headers which is not available in the thttprequest component.

Unfortunately I don't have access to the server logs to figure out what the issue was?

Regards,
Bala
Anonymous
Not applicable
Author

Hello,

You could access to your response header with tRESTClient.

 

((java.util.Map<String,java.util.List<String>>)globalMap.get("tRESTClient_1_HEADERS"))

Best regards

Sabrina

Anonymous
Not applicable
Author

Hi,

I get Error in trestclient for that particular request. The same request works well and good with thttprequest component.

The URL what I am trying to use will send the response in header which I can able to retrieve only in the trestclient not from the thtprequest component. I have attached the screenshots of the success response when I use thttprequest component and the Error response when using trestclient component.

 

Regards,

Bala

Anonymous
Not applicable
Author

Hi,

Sorry i think I missed the screen shots in the previous post

 

I get Error in trestclient for that particular request. The same request works well and good with thttprequest component.

The URL what I am trying to use will send the response in header which I can able to retrieve only in the trestclient not from the thtprequest component. I have attached the screenshots of the success response when I use thttprequest component and the Error response when using trestclient component.

 

Regards,

Bala


thttpSuccess.PNG
Trest_Error.PNG
Anonymous
Not applicable
Author

 

@Sujay @xdshi 

 

I tried to sniff the request via Wireshark...

 
The generated request is:
 
GET /api/v1/Group/1245676456456/$export HTTP/1.1
Content-Type: */*
Accept: application/json,application/fhir+json
Prefer: respond-async
Authorization: Bearer yJ9
User-Agent: Apache CXF 3.1.2
Cache-Control: no-cache
Pragma: no-cache
Host: my.host
Connection: keep-alive
 
 
It looks like tRestClient currently has a setting of "Accept" with the default values as "XML"/ "JSON"/ "any". Since my endpoint requires "application/fhir+json", I add that as an additional header.
 
However, the endpoint accepts only one "Accept" parameter... "application/fhir+json". This is causing my request to be failed.
 
Is there any quick way to handle this by customizing the tRestClient? I am thinking if I can add a new ACCEPT; for eg: FHIR with the value as "application/fhir+json", it could help?
 

Can someone help with this?

 

Regards,

Bala

 
Sujay1
Creator
Creator

Sorry   @baladevi  i don't have any such API to call with such "Accept".