所以,我的Java应用程序中有这个方法:
public String addAppointment(String service_id, String location_id, String start_date, String client_name, String client_phone, String client_email, String note, String session_token)
{
Map<String, String> args = new HashMap<String, String>();
args.put("service_id", service_id);
args.put("location_id", location_id);
args.put("start_date", start_date);
args.put("client_name", client_name);
args.put("client_phone", client_phone);
args.put("client_email", client_email);
args.put("note", note);
System.out.println(API_URL + "company/[censored]/appointment/?session_token="+ session_token);
String result = restTemplate.postForObject(API_URL + "company/[censored]/appointment/?session_token="+ session_token, args, String.class);
return result;
}
我收到了警告:
WARNING: POST request for "http://www.setster.com/api/v2/company/[censored]/appointment/?session_token=[censored]" resulted in 400 (Bad Request); invoking error handler
WARNING: StandardWrapperValve[setster]: PWC1406: Servlet.service() for servlet setster threw exception
当我更改该行时:
String result = restTemplate.postForObject(API_URL + "company/[censored]/appointment/?session_token="+ session_token, args, String.class);
有:
String result = restTemplate.getForObject(API_URL + "company/[censored]/appointment/?session_token="+ session_token, String.class, args);
我收到来自服务器的成功消息,并且回复正确。但是,POST URL很好,可以在PHP中使用CURL而没有任何问题。
所以我的问题是。我做错了什么?还有另一种方法可以使用 postForObject 创建帖子吗?