Skip to content

Instantly share code, notes, and snippets.

@nspeet
Last active July 26, 2019 15:30
Show Gist options
  • Save nspeet/ae4d5b00c15703ebe715024afd217cbe to your computer and use it in GitHub Desktop.
Save nspeet/ae4d5b00c15703ebe715024afd217cbe to your computer and use it in GitHub Desktop.
// add line item to Cart
using (var client = new HttpClient())
{
// assembledEndpoint: {{host}}/{{projectKey}}/me/carts/cartId
var endpoint = assembledEndpoint;
var body = new Dictionary<string, string>
{
{ "version", "1" },
{ "actions": [{
"action": "addLineItem",
"productId": "f5635f84-7c0b-4df7-8ea2-5134911cd5ea",
"variantId": 1
}]
},
};
var content = new FormUrlEncodedContent(body);
var response = await client.PostAsync(endpoint, content);
var responseString = await response.Content.ReadAsStringAsync();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment