从 Resttemplate 调用时不支持请求方法 'PUT'

Request method 'PUT' not supported When calling from Resttemplate

我必须使用 Resttemplate 调用 PUT 方法。我可以从 POST 人那里获得服务。但是当我使用 Resttemplate 尝试来自 Java 的相同请求时,它会抛出错误。我在做什么可能是错误的。

405 : [{"category":"ACCESS","code":"METHOD_NOT_SUPPORTED","description":"Request method 'PUT' not 
supported","httpStatusCode":"405"}]

@Autowired
@Qualifier("orderMasterUpdateClient")
private RestTemplate orderMasterUpdateClient; // Loading the template with credentials and URL

ResponseEntity<SalesOrderDocument> responseEntity = orderMasterUpdateClient.exchange(
                URL,
                HttpMethod.PUT,
                new HttpEntity<>(headers),
                SalesOrderDocument.class, changeRequest);

如果你想在 PUT 请求的主体中发送 changeRequest对象数据,我建议你使用下一个 RestTemplate 交换方法调用:

String url = "http://host/service";
ChangeRequest changeRequest = new ChangeRequest();
HttpHeaders httpHeaders = new HttpHeaders();
HttpEntity<ChangeRequest> httpEntity = new HttpEntity<>(changeRequest, httpHeaders);

ResponseEntity<ChangeRequest> response = restTemplate
            .exchange(url, HttpMethod.PUT, httpEntity, ChangeRequest.class);