我正在尝试从我的应用程序对Facebook的图形API进行POST调用。该方法的相关摘录是:
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Authorization","Bearer "+ accessToken);
HttpEntity<EventSetVM> request = new HttpEntity<>(new EventSetVM(eventSetName), headers);
Map<String, String> params = new HashMap<>();
params.put("name", eventSetName);
String url = "https://graph.facebook.com/v2.8/" +
businessManagerId +
"/offline_conversion_data_sets";
EventSetVM eventSetVM = restTemplate.postForObject(url, request, EventSetVM.class, params);
我从Firefox的RESTClient获得的错误是
{
"timestamp": 1487779045470,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.web.client.HttpClientErrorException",
"message": "400 Bad Request",
"path": "<correct-path-with-no-parameters>"
}
这里发生了什么?
答案 0 :(得分:1)
图表API在您的请求中需要显式的“access_token”参数。您需要在params中添加access_token参数。