Update Cart
code examples curl request patch \\ \ url https //app sparklayer io/api/v1/carts/{id} \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ header 'site id jones climbing' \\ \ data '{ "custom fields" \[ { "name" "" } ] }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("content type", "application/json"); myheaders append("site id", "jones climbing"); var raw = json stringify({ "custom fields" \[ { "name" "" } ] }); var requestoptions = { method 'patch', headers myheaders, body raw, redirect 'follow' }; fetch("https //app sparklayer io/api/v1/carts/{id}", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));require "uri" require "json" require "net/http" url = uri("https //app sparklayer io/api/v1/carts/{id}") https = net http new(url host, url port) https use ssl = true request = net http patch new(url) request\["accept"] = "application/json" request\["content type"] = "application/json" request\["site id"] = "jones climbing" request body = json dump({ "custom fields" \[ { "name" "" } ] }) response = https request(request) puts response read body import requests import json url = "https //app sparklayer io/api/v1/carts/{id}" payload = json dumps({ "custom fields" \[ { "name" "" } ] }) headers = { 'accept' 'application/json', 'content type' 'application/json', 'site id' 'jones climbing' } response = requests request("patch", url, headers=headers, data=payload) print(response text) responses // successful response { "cart" { "id" "", "intent" "", "customer id" "", "shipping address id" "", "billing address id" "", "items" \[ { "sku" "", "quantity" 0, "line total" { "net" "", "gross" "", "tax rate" "", "currency code" "", "tax inclusive display" false }, "unit total" {} } ], "totals" { "total" { "pre discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "charge" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" } }, "shipping" { "pre discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "charge" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" } }, "sub total" { "pre discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "discount" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" }, "charge" { "net" { "amount" "", "currency code" "" }, "gross" { "amount" "", "currency code" "" }, "tax" { "amount" "", "currency code" "" }, "apportioned tax rate" "", "currency" "" } } }, "customer addresses" \[ { "id" "", "uuid" "", "first name" "", "last name" "", "company" "", "description" "", "address line 1" "", "address line 2" "", "city" "", "postal code" "", "country code" "", "region code" "", "phone" "", "external id" "" } ], "shipping rate handle" "", "payment method" "", "validation errors" \[ "" ], "customer reference" "", "po number" "", "shipping requested date" "", "custom fields" \[ { "name" "", "value" "" } ] }, "item update results" \[ { "sku" "", "name" "", "requested quantity" 0, "resultant quantity" 0, "messages" \[ { "type" "" } ] } ] }// cart not found // unprocessable entity {}// error response