November Happy Hour will be moved to Thursday December 5th.

(Content Delivery Api Commerce) Can't get Cart API to work

Vote:
 

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.

#251283
Mar 24, 2021 12:31
Vote:
 

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.

#251298
Mar 24, 2021 13:47
Vote:
 

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.

#251299
Mar 24, 2021 13:57
Vote:
 

No you don't - the cartid for POST should be empty and will be created for you.

#251300
Mar 24, 2021 14:04
Vote:
 

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"

#251304
Edited, Mar 24, 2021 14:14
Vote:
 

I believe you need to post a non empty Guid for CustomerId as well 

#251305
Mar 24, 2021 14:16
Vote:
 

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?

#251306
Mar 24, 2021 14:19
Vote:
 

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)

#251307
Mar 24, 2021 14:39
Vote:
 
  1. No, but you can write a REST endpoint for that, using CustomerContext. Like any other headless APIs, they are just REST endpoints and you can add yours.
  2. Unfortunately I can't answer that (I'm not with Content API team, or even with Commerce team any more), I will however file a bug to Content API so they can improve the docs. 
#251308
Mar 24, 2021 14:43
Vote:
 

Thank you Quan!

#251309
Mar 24, 2021 14:49
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.