繁体   English   中英

我收到错误 org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request

[英]I am getting the Error org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request

我正在尝试使用 post 方法调用 Rest 服务。 我收到一个错误的请求错误,如下所述。 Rest服务是在WCF中开发的,请求参数只有一个String。

错误日志

org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request: [?xml version="1.0" encoding="utf-8"?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/... (3462 bytes)]

代码

System.out.println("Hi.................... I am in ###########################");
String testData="hashcode";

String response = restTemplate().postForObject("https://(...)/Rest/Register",testData, String.class, testData);
        
System.out.println("Hi.................... I am in ########################### "+response);

你能告诉我我的电话有什么问题吗?

你可以只使用:

String response = restTemplate().postForObject("https://(...)/Rest/Register",testData, String.class)

另外,如果这不起作用,您可以发布您的 API 吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM