Skip to content

Instantly share code, notes, and snippets.

@nspeet
Last active July 26, 2019 15:32
Show Gist options
  • Save nspeet/3bdb3327beb4f93b0c7d227424f2200d to your computer and use it in GitHub Desktop.
Save nspeet/3bdb3327beb4f93b0c7d227424f2200d to your computer and use it in GitHub Desktop.
HTTP request C#
// Create Cart
using (var client = new HttpClient())
{
// assembledEndpoint: {{host}}/{{projectKey}}/me/carts
var endpoint = assembledEndpoint;
var body = new Dictionary<string, string>
{
{ "currency", "USD" },
{ "shippingAddress", {
"country": "US"
}
},
};
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