Adding line-item to a basket
The first thing you need to do is to attach your AccessToken token to the request's header. See Quick Start if you are not sure how to do that.
Second you should add the desired basketId
as query parameter like this:
api/v1/baskets/adfad2d7-e808-4268-8dfa-e8a5611011e5/lines
Third, to add new line-item to the basket, your request should have a body with required properties:
- CultureCode
- Quantity
- Sku
- PriceGroupId
- ProductCatalogId
There are two optional properties:
AddToExistingOrderLine
, by default is set totrue
. If you set it tofalse
a new order line will be added.VariantSku
An example could be:
curl -D- -X POST https://umbracodemo1.ucommerce.net/api/v1/baskets/{baketId}/lines \ -H 'Authorization: Bearer <ACCESS_TOKEN>' -H 'Content-Type: application/json' \ -d '{ "Quantity": 10, "Sku": "BWWMSFSS-LE", "VariantSku": "BWWMSFSS-LE-15-White", "PriceGroupId": "878b0ff1-0800-40ac-b006-0e9858f234a5", "ProductCatalogId": "7d27a01f-21e1-4adb-afc2-490c284bd478", "CultureCode": "en-US" }'
Possible errors that may occur:
Error | Description |
---|---|
BadRequest (400) | Product does not exist; Price Group does not exist; Order Line does not exists; Mismatch between Basket and Price Group's currency; Execution of the pipeline fails |
NotFound (404) | Basket does not exist |
Unauthorized (401) | The token expires |
Forbidden (403) | The token does not have access to this endpoint |
Example:
{ "errors": [ { "error-description": "Basket does not exist.", "error": "NotFound" } ] }
See Handling failures for more info.