Skip to main content

Announcements
Week 4: Discover ELT + ETL Strategies and Explore Predictive AI in Qlik Cloud - WATCH NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Consume REST API with 1 header

Hi,

 

I'm trying to call a simple 'Hello World' REST API via the GET verb. The API is only expecting one HTTP Header, Accept application/json which i've set in the advanced settings of my tRestClient component. However, Talend seems to automatically create another entry for the contents of the Accept Type dropdown. When i run I’m getting HTTP 406 Not Acceptable back because the API is not expecting 2 headers. 

 

I've tested this API with other software and it responds correctly so it must be down to Talend configuration. Anybody know a way around this or had a similar issue they've resolved?

 

I have screenshots but unfortunately they're being blocked by my firewall at work. Sorry

 

Thanks

Matt

 

 

Labels (4)
21 Replies
Anonymous
Not applicable
Author

The top image is not very clear (Advanced Settings). I assume you are setting your bespoke Accept type there. Can you show us what this is? Why have you starred out part of the value? It shouldn't need to be secret and might help knowing what this is

Anonymous
Not applicable
Author

This is the API spec

 

Request headers

Name           Value

Accept      application/vnd.hmrc.1.0+json

 

Authorisation
This resource is open access - no Authorization header is required.

 

Response
HTTP status: 200 (OK)

{
"message" : "Hello World"
}

 

Anonymous
Not applicable
Author

OK, this is strange behaviour from the web service. I've figured it out (I guessed the service you were trying to use). It appears that it is rejecting multiple Accept types.....which I don't believe it should. The best way to get around this is to use the tRest component. I have just tested it and it worked straight away if you follow the screenshot I have added.....0683p000009LsJJ.png

 

By the way, for a public service like HMRC there is no need to be secretive about the host of the service. Obviously don't give away personal login credentials, but when there is a public test service, feel free to give that information. With access to the service I was able to try out a few things very quickly.

Anonymous
Not applicable
Author

Ok thanks really appreciate your help and advice.

 

I'm trying tRest and now i get a different error (maybe this should be a new post). When i configure tRest the same as you i get 

 

 

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
com.sun.jersey cannot be resolved to a type
com.sun.jersey.client cannot be resolved to a variable
com.sun.jersey.api.client.Client cannot be resolved to a type


I've checked and i have both jersey-client-1.4.jar and jersey-core-1.4.jar installed. I've tried using a tLibraryLoad to make sure these are loaded but still get the error. Any ideas?

 

 

 

Anonymous
Not applicable
Author

What version of Talend are you using? I'm using 6.2.1 at the moment and have not had to do anything special to use this component with no problems.

 

Can you check your ../workspace/Java/lib folder for the jerset-core-1.4.jar and jersey-client-1.4.jar?

Anonymous
Not applicable
Author

I'm on 6.4.1 and the two jar files are in both Workspace\.Java\lib and Talend\6.4.1\studio\configuration\.m2\repository\org\talend\libraries

 

I've asked a colleague on the same version to test and they can compile the same job on their machine. Going to check my java paths are set up correctly. 

Anonymous
Not applicable
Author

OK, I would recommend just reinstalling Studio. I have seen this sort of problem happen quite a few times. It is probably quicker to reinstall than try to hunt through the broken install. Ensure you have backed up your project if you are not using the Enterprise Edition.

Anonymous
Not applicable
Author

Ok thanks. I've sent the job to a colleague and they can run it ok so it's definietly something wrong with Studio on my machine. Will try reinstalling. Thanks for all your help. 

Anonymous
Not applicable
Author

This issue was solved by overwriting both jersey-client-1.4-6.0.0.jar and jersey-client-1.4-6.0.0.jar with the version from a colleague's PC.

Anonymous
Not applicable
Author

That's weird. I guess they got corrupted somehow. Did you try to replace them prior to having the issue?