Skip to content

Instantly share code, notes, and snippets.

@JoachimL
Created March 19, 2017 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoachimL/16cedc5d5e45773a41b758ae47b40121 to your computer and use it in GitHub Desktop.
Save JoachimL/16cedc5d5e45773a41b758ae47b40121 to your computer and use it in GitHub Desktop.
Add product to kolonial cart
public static async Task AddProductToCartAsync(HttpClient httpClient, KolonialProduct kolonialProduct, TraceWriter log)
{
var productsJson = JsonConvert.SerializeObject(
new { items = new []{ new { product_id = kolonialProduct.Id, quantity = 1 } }});
log.Info($"Updating Kolonial with {productsJson}");
var response = await httpClient.PostAsync(
"https://kolonial.no/api/v1/cart/items/",
new StringContent(productsJson, Encoding.UTF8, "application/json"));
response.EnsureSuccessStatusCode();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment