【发布时间】:2022-08-03 01:07:53
【问题描述】:
我正在尝试使用 Spring 的 WebClient 使用 vCenter REST API 生成支持包。当我使用 cURL 触发包创建(甚至伪造标头以模拟 Java 发送的内容)时,一切正常:
$ curl -A \"Apache-HttpAsyncClient/5.1 (Java/14.0.2)\" -X POST \'https://vcenter.internal.system:443/api/appliance/support-bundle?vmw-task=true\' -H \'vmware-api-session-id: 4d63eec20a2fd6baadfef6ba9c308f92\' -H \'Content-type: application/json\' -d \'{ \"components\": { \"VirtualAppliance\": [ \"ApplianceManagement\", \"Rhttpproxy\" ] }, \"description\": \"bundle\", \"partition\": \"\" }\' --insecure
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 204 0 74 100 130 217 382 --:--:-- --:--:-- --:--:-- 601\"8459589f-0bcc-4a88-b579-8996c97c66aa:com.vmware.appliance.support_bundle\"
当我从 WebClient 执行相同操作时,我收到一个奇怪的 HTTP 400 错误:
{
\"error_type\": \"INVALID_ARGUMENT\",
\"messages\": [
{
\"args\": [
\"operation-input\",
\"spec\"
],
\"default_message\": \"Structure operation-input is missing a field \\\"spec\\\"\",
\"id\": \"vapi.data.structure.field.missing\"
}
]
}
通过向 cURL 和 Apache 的 HTTP 客户端添加一些详细的日志记录,我看到发送的正文和标头是相同的,所以这是一个谜。
标签: spring-webclient vcenter apache-httpclient-5.x