Я использую шаблон Spring Rest для выполнения операции удаления.
Я получаю 400 плохих запросов. Однако тот же запрос работает с почтальоном.
URL: http://localhost:8080/product-service/customer/123456/customer-items/US?productCode=A-124896
Код контроллера:
@DeleteMapping(value = "/customer/{customer-number}/customer-items/{country}", params = {"uline-item-number"} , produces = {"application/json"})
public ResponseEntity<Boolean> deleteCustomerItem( @PathVariable("customer-number") final String customerNumber,
@PathVariable("country") final String countryCode,
@RequestParam("productCode") final String productCode) {
try {
return new ResponseEntity<>(appCustomerService.deleteCustomerItem(customerNumber, countryCode, productCode), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
Сервисный номер:
public Boolean deleteCustomerItem(String customerNumber, String countryCode, String productCode)
throws Exception{
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("productCode", productCode);
String productUrl = http://localhost:8080/product-service/customer/123456/customer-items/US";
try {
restTemplate.exchange(productUrl , HttpMethod.DELETE, HttpEntity.EMPTY, Void.class, uriVariables);
return true;
} catch (Exception e) {
throw new Exception(e.getMessage());
}
}
Я что-то упустил в запросе? Пожалуйста, помогите мне решить эту проблему.