【发布时间】:2018-08-22 15:35:04
【问题描述】:
使用 IBM MobileFirst 8.0 平台,我正在探索从其他 Java 适配器端点调用 Java 适配器端点的选项。
IBM 解释的示例(此处)非常简单,并且适用于 GET 方法。简化如下:
String otherAdapterUrlendPoint = "/otherAdapter/endpoint?param="+param;
HttpUriRequest req = new HttpGet(otherAdapterUrlendPoint);
HttpResponse response = adaptersAPI.executeAdapterRequest(req);
这里的问题是 POST 方法(或 PUT 或 DELETE)会发生什么?我没有找到任何文档,也没有找到示例。我虽然可能是这样的:
HttpPost httpPost = new HttpPost(otherAdapterUrlendPoint);
...
<<do something with httpPost object>>
...
HttpUriRequest req = httpPost;
HttpResponse response = adaptersAPI.executeAdapterRequest(req);
但我不确定如何将 json 正文添加到此请求中...(关于标头,我想我可以使用方法 httpPost.addHeader(name, value));
有人可以帮我解决这个疑问吗?我很确定这不是 IBM MobileFirst 主题,而是 Java 主题...
提前致谢!
【问题讨论】:
标签: java http-post ibm-mobilefirst mobilefirst-server