我想做一个postForEntity
,但结果始终为空。可能是什么原因?
@Override
public ResponseEntity<Void> updateContactProperty(final Long contactId,final String json) throws RestClientException {
ResponseEntity<Void> crmResponse = null;
try {
crmResponse = crmRestTemplate.postForEntity(
"https://api.hubapi.com/contacts/v1/contact/vid/400000001/profile?hapikey=myApiKey",json,Void.class);
} catch (HttpClientErrorException e) {
e.printStackTrace();
} catch (HttpStatusCodeException e) {
e.printStackTrace();
}catch (RestClientException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} catch (Error r) {
r.printStackTrace();
} catch (Throwable t) {
t.printStackTrace();
}
return crmResponse;
}
我尝试了ResponseEntity<Void>
,ResponseEntity<Object>
,ResponseEntity<String>
。
已在RestTemplate中注册的MessageConverters:
- ByteArrayHttpMessageConverter
- StringHttpMessageConverter
- ResourceHttpMessageConverter
- SourceHttpMessageConverter
- AllEncompassingFormHttpMessageConverter
- Jaxb2RootElementHttpMessageConverter
- MappingJackson2HttpMessageConverter
没有异常可以捕获...只是进行了呼叫,但是什么也没发生。