400: [no body] -向服务器发送POST请求时错误的请求



我已经生成了(openapi)有效载荷对象。

@JsonPropertyOrder({
MyPayload.JSON_PROPERTY_MY_PROPERTY
})
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = ...")
public class MyPayload {
public static final String JSON_PROPERTY_MY_PROPERTY = "my_properties";
private Map<String, MyPropery> myProperties = null;
...
}

当我的客户端微服务发送post请求-它失败了

org.springframework.web.client.HttpClientErrorException$BadRequest: 400 : [no body]

然而,如果我将发送纯Json作为邮差的有效载荷-似乎工作良好,来到服务器。

就我对客户端问题的理解,找不到原因(

)我的客户端代码(spring-web 5.3.14)

private MyClient getMyClient() {
MyClient myClient = new MyClient();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build());
RestTemplate restTemplate = new RestTemplate(requestFactory);
restTemplate.setInterceptors(
Collections.singletonList(
(ClientHttpRequestInterceptor) new TenantAwareClientInterceptor(storage)));
ApiClient apiClient = new ApiClient(restTemplate);
apiClient.setBasePath("https://myMS:poty/api/v1/...");
myClient.setApiClient(apiClient);
return myClient;
}

可能是因为我的有效负载中的对象和服务器端解组的对象之间存在一些差异吗?

乌利希期刊指南:有效载荷似乎有问题。当我创建所有字段为null的有效载荷时-一切都工作正常…

负载可能有什么问题?

我想我已经找到原因了。发生这种情况是由于在我的有效负载中的一个成员的基类中缺少属性。

详情如下

最新更新