简体   繁体   中英

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

I am trying to call a Rest Service with post method. I am getting a bad request Error as mentioned below. Rest service is developed in WCF, with only one String as request parameter.

Error Log

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

Code

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

Can you please suggest me what's wrong in my calling?

Can you use just:

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

Also if this doesn't work could you post your API also?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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