问题
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>HTTP Headers of my tRestClient component. However, looking at the code tab, 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.
Thanks
回答1:
tRESTClient
defines its http headers based on the parameters you supply in the component settings. It has an "Accept Type
" setting, which you can set to "JSON
", this adds the http header "Accept: application/json
" (this way you don't have to add it in the http headers section).
For your use case, you can also use tREST
, which allows you to have complete control over http headers, it only sends those you set in the http headers section.
来源:https://stackoverflow.com/questions/48586057/talend-trestclient-consume-rest-api-with-1-header