400使用restemplate.postforobject调用api时请求错误

pes8fvy9  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(131)

我试图使用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/
谢谢你的阅读。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题