1# Create a new basket in the Shop API:2REQUEST:3POST /dw/shop/v23_1/baskets4Host: example.com5Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX6Content-Type: application/json78# in case of success, response contains new created basket with the resource state in response9# header and also as single property in response body10RESPONSE:11HTTP/1.1 200 OK12Content-Length:12413x-dw-resource-state:ba4e84383e1790597e49eeee34b201633d80ed3f499992f5af11d639dd903a3614Content-Type:application/json;charset=UTF-815{16 "_resource_state" : "ba4e84383e1790597e49eeee34b201633d80ed3f499992f5af11d639dd903a36",17 ...18 "basket_id" : "bczFTaOjgEqUkaaadkvHwbgrP5",19 ...20}2122# Search for stores in the Data API:23REQUEST:24POST /s/-/dw/data/v23_1/sites/SiteGenesis/store_search HTTP/1.125Host: example.com26Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c450736727...2829# in case of success, response contains multiple resource states - one per search hit30RESPONSE:31HTTP/1.1 200 OK32{33 ...34 "hits" : [{35 "_resource_state" : "12ab34cd",36 "id" : ...37 },{38 "_resource_state" : "ef56gh78",39 "id" : ...40 }]41}
1# add an item to the basket, the resource state from the response header is given as x-dw-resource-state2# header ...3REQUEST:4POST /dw/shop/v23_1/baskets/bczFTaOjgEqUkaaadkvHwbgrP5/items?client_id=af123-456....5Host: example.com6Authorization:Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX7x-dw-resource-state:ba4e84383e1790597e49eeee34b201633d80ed3f499992f5af11d639dd903a368Content-Type: application/json9{10...11}1213# ... or as _resource_state property in the body1415# Add an item to the basket, send resource state via body1617REQUEST:18POST /dw/shop/v23_1/baskets/bczFTaOjgEqUkaaadkvHwbgrP5/items19Host: example.com20Authorization: Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX21Content-Type: application/json22{23 "_resource_state" : "ba4e84383e1790597e49eeee34b201633d80ed3f499992f5af11d639dd903a36"24 ...25}2627# in case of success, the next response header contains a new resource state28RESPONSE:29HTTP/1.1 200 OK30Content-Length:12431x-dw-resource-state: ba4e84383e1790597e49eeee34b201633d80ed3f499992f5af11d639dd903a3632Content-Type:application/json;charset=UTF-833{34 "_resource_state" : "ba4e84383e1790597e49eeee34b201633d80ed3f499992f5af11d639dd903a36"35 ...36 "basket_id" : "bczFTaOjgEqUkaaadkvHwbgrP5",37 ...38}3940# Delete an item from the basket, resource state is send via header4142REQUEST:43DELETE /dw/shop/v23_1/baskets/bczFTaOjgEqUkaaadkvHwbgrP5/items/te352d63gdh62hd6hd44Host: example.com45Authorization: Bearer eyJfdiI6IjXXXXXX.eyJfdiI6IjEiLCJleHAXXXXXXX.-d5wQW4c4O4wt-Zkl7_fiEiALW1XXXX46x-dw-resource-state: 10000147Content-Length: 04849# in case of creating a not existent customer5051REQUEST:52PUT /s/-/dw/data/v23_1/customer_lists/4711/customers/0815 HTTP/1.153Host: example.com54Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c450736755Content-Type: application/json; charset=UTF-856{57 "_resource_state" : "not_exists",58 "email" : "dude@salesforce.com",59 ...60}6162# when a customer with that ID already exists6364RESPONSE:65HTTP/1.1 409 CONFLICT66Content-Type: application/json;charset=UTF-867{68 "_v" : "23.1",69 "_type" : "fault",70 "fault" : {71 "type" : "ResourceAlreadyExistsException",72 "message" : "Resource already exists, state is 'ab12cd34'."73 }74}
j
DID THIS ARTICLE SOLVE YOUR ISSUE? Let us know so we can improve!