Talend tRestClient 使用 1 个标头的 REST API [英] Talend tRestClient Consume REST API with 1 header

查看:35
本文介绍了Talend tRestClient 使用 1 个标头的 REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 GET 动词调用一个简单的Hello World"REST API.API 只需要一个 HTTP 标头,接受应用程序/json,我在我的 tRestClient 组件的高级设置>HTTP 标头中设置了它.但是,查看代码选项卡,Talend 似乎会自动为 Accept Type 下拉列表的内容创建另一个条目.当我运行时,我收到 HTTP 406 Not Acceptable 返回,因为 API 不需要 2 个标头.

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.

我已经用其他软件测试了这个 API,它响应正确,所以它必须归结为 Talend 配置.有人知道解决这个问题的方法或解决过类似的问题吗?

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.

谢谢

推荐答案

tRESTClient 根据您在组件设置中提供的参数定义其 http 标头.它有一个Accept Type"设置,您可以将其设置为JSON",这会添加 http 标头Accept: application/json""(这样您就不必将其添加到 http 标头部分).

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).

对于您的用例,您还可以使用 tREST,它允许您完全控制 http 标头,它只发送您在 http 标头部分设置的那些.

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.

这篇关于Talend tRestClient 使用 1 个标头的 REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆