I am not an expert but I understand that you need to work with a special guid, not with 2 or 4. You can try to post to /carts/ to create a new one, and use that guid for later use.
When I look at the API for POSTing to /carts/ it looks like I need to supply a guid there for the cart? It doesn't look like I can create a new cart without an existing GUID?
I haven't been able to create a cart via the API, it's not really documented what all fields are and how I get the correct data to put in there.
No you don't - the cartid for POST should be empty and will be created for you.
Swagger comes to help https://world.episerver.com/documentation/developer-guides/content-delivery-api/api-fundamentals/cartapi/#/CartApi/CartApi_Get
Ok am I misunderstanding the swagger information?
I try posting to /carts/:
{
"Name": "TestCart",
"Market": "US",
"Currency": "USD"
}
With working Authorization header.
And I still get "Bad request"
Ok, that actually worked. But I had to get CustomerId manually from CM. Is there any way to get the authorized useres CustomerId from the API?
Is the Cart API "done"? It feels unclear how to add lineitems, shippingmethod etc. And as our conversation above proved, the Swagger docs can't really be trusted (CustomerId is not marked as required)
I'm playing around with the Foundation project, which has Epi Content Delivery API installed, with the Commerce API aswell.
Using the API I can login and get a token, I can request some resources, for example I can get the default warehouse.
But when I try to use the api/episerver/v2.0/carts/ endpoint, I only get 404 even though I put in existing Cart IDs.
For example, in admin / commerce manager I can see I have 2 carts, one with id "2" and one with id "4".
I've tried posting a get to api/episerver/v2.0/carts/4 and api/episerver/v2.0/carts/2, but I only get back 404. If I put something bad like api/episerver/v2.0/carts/00000000-0000-0000-0000-000000000000 I do get 400 - Bad Request. So it seems like the endpoint is listening, but not responding correctly.
I've tried both with and without the Authorization header.