简体   繁体   中英

Spring Boot RestTemplate post without response type

I need to call another api and I am trying to use postForEntity as below:

restTemplate.postForEntity(postUrl, request, responseType)

Now, the api that I am calling is returning an object of a particular type, let's say CustomerDto. But I am not interested in this object. I just want to post and I don't want anything in return so I don't want to create this CustomerDto class in my application. So, for this scenario, in the above statement, what should i replace for responseType. In case, I had wanted the returned object, I would have given CustomerDto.class in case of responseType, but I dont want anything in return, so what do I do?

您可以使用postForLocation而不是postForEntity

restTemplate.postForLocation(postUrl, request)

另一种方法是使用Void.class作为响应类型

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM