My Products
Help

SalesOrder API POST/PATCH cumbersome because of ETag/If-Match

by Gert-Jan van der Kamp (Updated ‎20-06-2024 11:30 by Gert-Jan van der Kamp )

Hi all, 

 

Right now the ETag header is only returned for GET requests, but (the latest) is required for PATCH and POST. When I need to update an order that leads to the following flow: 

  1. GET /api/v3/SalesOrders/${OrderType}/${OrderId}  // get whole order just for etag header 
  2. PATCH /api/v3/SalesOrders/${OrderType}/${OrderId}  // use etag to update Order
  3. GET /api/v3/SalesOrders/${OrderType}/${OrderId}  // get etag header again
  4. DELETE /api/v3/SalesOrders/${OrderType}/${OrderId} /lines?lineIds=1,2,3,4,5  // use etag to delete lines 
  5. GET /api/v3/SalesOrders/${OrderType}/${OrderId}  // get etag header again
  6. POST /api/v3/SalesOrders/${OrderType}/${OrderId} /lines  // use etag to insert lines 

 

Doing a full get is a bit wasteful and introduces added calls/latency.

Could you guys include the ETag header in the reply for POST, PATCH and DELETE? Ideally also include a HEAD to get it without getting the full Order. 

 

That could shorten the flow above to:

  1. HEAD /api/v3/SalesOrders/${OrderType}/${OrderId}  // get etag header, no data
  2. PATCH /api/v3/SalesOrders/${OrderType}/${OrderId}  // use etag from above and capture eTAG from reply
  3. DELETE /api/v3/SalesOrders/${OrderType}/${OrderId} /lines?lineIds=1,2,3,4,5  // use from above and  capture eTAG from reply
  4. POST /api/v3/SalesOrders/${OrderType}/${OrderId} /lines // use etag from above 

 

That 6 calls would be 4 and smaller ones too, saving round trips and bandwith. 

 

 

 

1 REPLY 1
Accepted solution
Gert-Jan van der Kamp
CHAMPION *

by Gert-Jan van der Kamp

Sorry never mind must have been cross-eyed yesterday night I see the ETag now. Can;t delete this post.