i am trying to update an order based on the return process. If the return process is done, the order statusId and the statusIds of the positions of an order has to be updated.
I have already managed to update the statusId of the order through this endpoint /api/orders/15 (PUT-Request). But this Endpoint only allows few parameters to be updated. Here is the shopware 5 api documentation: https://developers.shopware.com/developers-guide/rest-api/examples/order/
Is there another way to update the positions? Or do i have to update it in the database directly? This seems to be very dirty.
I am using Spring Boot to make the requests. Here is the code for updating the order statusId
private JSONObject setShopwareOrderStatus(ReturnOrder order, SetOrderStatusRequest orderStatus) {
String apiUrl = String.format("https://shop.com/api/orders/%d?useNumberAsId=true", order.getOrderId());
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set(HttpHeaders.AUTHORIZATION, "Basic apiToken");
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
HttpEntity<SetOrderStatusRequest> request = new HttpEntity<>(
orderStatus, headers);
ResponseEntity<String> responseEntity =
restTemplate.exchange(apiUrl, HttpMethod.PUT, request, String.class);
return new JSONObject(responseEntity.getBody());
}
Hope someone is able to help me