Add/Remove Cart Item API

What is the Add/Remove Cart Item API?

The Add/Remove Cart Item API is to be used in combination with other Cart APIs: Cart Item Creation API and Cart Creation API. This API provides you with possibility to modify your cart after its creation: removing already added items or adding new items to it.

Who Should Use this API?

This API is intended to be used in white label business model approach when you have a full control on placing orders to our backend system.

Try it Out

Do you have questions about how your server should add/remove cart items to/from cart? Visiting our demo page will help you out.

We’ve developed a sandbox server, which is an isolated server (not hooked up to a payment system or production environment, allowing you to test the service without getting billed) to try out your code and integration with us. As the sandbox server is an isolated server, it requires different credentials than the production site.

The demo page of Add/Remove Cart Item API on sandbox server:

https://imatsandbox.materialise.net/api/demo/add-remove-cart-item.htm

The sandbox and production server contain API demo pages which send well-formed API requests to our site.

The demo page of Add/Remove Cart Item API on production server:

https://i.materialise.com/api/demo/add-remove-cart-item.htm

How Does it Work?

This API requires the personal API code. It is therefore not possible to use AJAX requests.

The Add/Remove Cart Item API works by posting data to our service.

You can use either XML or JSON formats for posting. The HTTP encoding type of a particular request depends on the type of API you are going to use. This will be described in the corresponding section of this page.

To specify the exact content type which your client can accept and parse, the Accept header in your request has to be set to one of the following encoding types:

• text/json
• text/xml

To add/remove cart item to/from cart through the Add/Remove Cart Item API, POST a well-structured request via “HTTPS” to this URL:

https://i.materialise.com/web-api/cart/{cartid}/items

To use APIs of the sandbox, the POST needs to be submitted to:

https://imatsandbox.materialise.net/web-api/cart/{cartid}/items

The server will return a structured response in XML or JSON which your application can parse.

Adding of cart items should be done using:

Request Method:POST

Removal of cart items should be done using:

Request Method:DELETE

Documentation

This API can be used whenever you need to add more items after cart is created or remove the item form your cart. Both operation can be done only before cart is ordered. In order to add or remove cart items, you need to know following data:

• ID of the cart to add/remove items
• ID of the cart item to be added/removed

Structure of the Request

Parameter Type Required? Explanation
cartItem List of parameters Yes Parent node of cart items to be added or removed from the cart
cartItem>cartItemID String (36), required format: Guid Yes Cart item ID. Few cart items can be specified. In order to create cart item from the model, use Cart Item Creation API

Request examples

Example of request in JSON

{
    "CartItems":[
        { 
            "CartItemID": "333095fc-6ab2-4c30-b0d1-baecfd708f69"
        }]
    }
}

Example of request in XML

 
<CartItemsRequest>
    <CartItems>
        <CartItem>
            <CartItemID>333095fc-6ab2-4c30-b0d1-baecfd708f69</CartItemID>
        </CartItem>
    </CartItems>
</CartItemsRequest>

Structure of the Response

Response Examples

Parameter Type Always shown? Description
cartItems List of parameters Yes Parent node of cart items list
cartItems>cartItem List of parameters Yes Parent node of cart items parameters. See next section for details.
cartItem>cartItemID String (36), required format: Guid Yes Cart item ID from request.
cartItem>myCartItemReference String Yes Echoed from the request of Cart Item Creation API.
cartItem>toolID String Yes Tool ID used to create cart item
cartItem>modelID String Yes ID of the model from cart item entity
cartItem>fileUnits String Yes Model file units: mm or inch
cartItem>fileScaleFactor Decimal, separated by a period Yes Model scale factor
cartItem>materialID String Yes Material ID
cartItem>finishID String Yes Finish ID
cartItem>quantity Integer Yes Number of pieces
cartItem>mySalesUnitPrice Decimal, separated by a period Yes Your sales price
cartItem>iMatUnitPrice Decimal, separated by a period Yes Calculated i.materialise price for one piece
cartItem>currency String Yes

Following currencies are supported: EUR/USD/JPY/GBP.

cartItem>validUntil ISODateTime Yes Cart item expiration date
error List of parameters No Parent node of cart item errors.
error>code Integer Yes Error code
error>message String Yes Error message

Example of Response in JSON

StatusCode: 200

StatusText: OK

Response:
{
    "cartItems":[
        {
            "cartItemID":"333095fc-6ab2-4c30-b0d1-baecfd708f69",
            "myCartItemReference":"some reference",
            "toolID":"2054608d-b469-4cab-adeb-cf1c0569e7a1",
            "modelID":"06515f8e-5d08-4fcb-912a-b87380d69927",
            "fileUnits":"mm",
            "fileScaleFactor":1.0000000000,
            "materialID":"035f4772-da8a-400b-8be4-2dd344b28ddb",
            "finishID":"bba2bebb-8895-4049-aeb0-ab651cee2597",
            "quantity":1,
            "mySalesUnitPrice":15.0000,
            "iMatUnitPrice":12.5000,
            "currency":"EUR",
            "validUntil":"2014-11-26T16:54:34.937"
        }
    ]
}

Example of Response in XML

StatusCode: 200

StatusText: OK

Response:
<CartItemsResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CartItems>
    <CartItem>
      <CartItemID>333095fc-6ab2-4c30-b0d1-baecfd708f69</CartItemID>
      <MyCartItemReference>some reference</MyCartItemReference>
      <ToolID>2054608d-b469-4cab-adeb-cf1c0569e7a1</ToolID>
      <ModelID>06515f8e-5d08-4fcb-912a-b87380d69927</ModelID>
      <FileUnits>mm</FileUnits>
      <FileScaleFactor>1.0000000000</FileScaleFactor>
      <MaterialID>035f4772-da8a-400b-8be4-2dd344b28ddb</MaterialID>
      <FinishID>bba2bebb-8895-4049-aeb0-ab651cee2597</FinishID>
      <Quantity>1</Quantity>
      <MySalesUnitPrice>15.0000</MySalesUnitPrice>
      <IMatUnitPrice>12.5000</IMatUnitPrice>
      <Currency>EUR</Currency>
      <ValidUntil>2014-11-26T16:54:34.937</ValidUntil>
    </CartItem>
  </CartItems>
</CartItemsResponse>

Errors Section of the Response

CodeMessage
101 Specified Cart does not belong to partner.
102 Specified Cart was not found or wrong format.
103 CartItemID is of wrong format
105 Cannot add/remove items. Specified Cart was already ordered.
106 Not found
107 CartItem validity period expired on {0}
108 CartItem already added to cart
109 CartItem not found in cart
110 Cannot add/remove items. Specified Cart was already checked out or ordered.
111 Cannot add/remove items. Specified Cart has expired.

Example of Response with error in JSON

StatusCode: 403

StatusText: Forbidden

Response:
{
    "cartItems":[
        {
            "error":{
                "message":"CartItem already added to cart",
                "code":108
            },
            "cartItemID":"333095fc-6ab2-4c30-b0d1-baecfd708f69"
        }
    ]
}

Example of Response with error in XML

StatusCode: 403

StatusText: Forbidden

Response:
<CartItemsResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CartItems>
    <CartItem>
      <Error>
        <Message>CartItem not found in cart</Message>
        <Code>109</Code>
      </Error>
      <CartItemID>333095fc-6ab2-4c30-b0d1-baecfd708f69</CartItemID>
      <ToolID xsi:nil="true" />
      <ModelID xsi:nil="true" />
      <FileScaleFactor xsi:nil="true" />
      <MaterialID xsi:nil="true" />
      <FinishID xsi:nil="true" />
      <Quantity xsi:nil="true" />
      <MySalesUnitPrice xsi:nil="true" />
      <IMatUnitPrice xsi:nil="true" />
      <ValidUntil xsi:nil="true" />
    </CartItem>
  </CartItems>
</CartItemsResponse>