Empty cart (cart decoupled) - Fabric
Empty cart (cart decoupled)
cURL
curl --request PATCH \
--url https://prod01-apigw.yourcompany.fabric.zone/api-cart/cart-decoupled/{cartId}/empty \
--header 'x-site-context: <x-site-context>'
Python
import requests
url = "https://prod01-apigw.yourcompany.fabric.zone/api-cart/cart-decoupled/{cartId}/empty"
headers = {"x-site-context": "<x-site-context>"}
response = requests.patch(url, headers=headers)
print(response.text)
JavaScript (Fetch API)
const options = {method: 'PATCH', headers: {'x-site-context': '<x-site-context>'}};
fetch('https://prod01-apigw.yourcompany.fabric.zone/api-cart/cart-decoupled/{cartId}/empty', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [\
CURLOPT_URL => "https://prod01-apigw.yourcompany.fabric.zone/api-cart/cart-decoupled/{cartId}/empty",\
CURLOPT_RETURNTRANSFER => true,\
CURLOPT_ENCODING => "",\
CURLOPT_MAXREDIRS => 10,\
CURLOPT_TIMEOUT => 30,\
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
CURLOPT_CUSTOMREQUEST => "PATCH",\
CURLOPT_HTTPHEADER => [\
"x-site-context: <x-site-context>"\
],\
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://prod01-apigw.yourcompany.fabric.zone/api-cart/cart-decoupled/{cartId}/empty"
req, _ := http.NewRequest("PATCH", url, nil)
req.Header.Add("x-site-context", "<x-site-context>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Unirest (Java)
HttpResponse<String> response = Unirest.patch("https://prod01-apigw.yourcompany.fabric.zone/api-cart/cart-decoupled/{cartId}/empty")
.header("x-site-context", "<x-site-context>")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://prod01-apigw.yourcompany.fabric.zone/api-cart/cart-decoupled/{cartId}/empty")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-site-context"] = '<x-site-context>'
response = http.request(request)
puts response.read_body
Response Codes
- 200: Remove all items in cart
- 400: Bad Request
- 404: Not Found
- 500: Internal Server Error
Example JSON Response
{
"registeredUser": false,
"account": "<string>",
"approver": "<string>",
"po": "<string>",
"cartId": 111166,
"status": "pending",
"allPromosApplied": "<array>",
"attributes": "<array>",
"__v": 0,
"totalAmount": {
"currency": "USD",
"amount": 38
},
"quantity": 2,
"_id": "5fee9d59f2f08a1b3cbdea08",
"createdAt": "2020-12-31T02:09:53.914Z",
"updatedAt": "2020-12-31T02:09:53.914Z",
"deleted": false,
"items": "<array>"
}
Error Response Example
{
"code": "CART_NOT_FOUND",
"message": "Cart not found."
}
Headers
x-site-context
- Type: string
- Required: Yes
- Description: The
x-site-context header is a JSON object that contains information about the source you wish to pull from. The mandatory account is the 24 character identifier found in Copilot. The channel, stage, and date attributes can be used to further narrow the scope of your data source.
Path Parameters
cartId
- Type: string
- Required: Yes
- Required string length: 24