我试图使用restemplate将数据发布到我的api,但发布时它返回400个错误请求异常。我怎么能修好它?
public void postDataToApi(List<String> accountIds, String myApiUrl) {
ObjectMapper mapper = new ObjectMapper();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
String accountIdsJsonList = mapper.writeValueAsString(accountIds);
HttpEntity<String> entity = new HttpEntity<String>(accountIdsJsonList, headers);
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.postForObject(myApiUrl, entity, String.class);
}
我想发布数据的api是yahooapi
https://ads-developers.yahoo.co.jp/reference/ads-search-api/v4/budgetorderservice/get/en/
谢谢你的阅读。
暂无答案!
目前还没有任何答案,快来回答吧!