Search code examples
c#apicampaign-monitor

Campaign Monitor Post with API Key


I'm new to this so what I want to do is post an Ajax to campaign monitor to add a new subscriber to a my list. The issue here is that I've carried out the right procedures using Campaign Monitors documentation. However I get a 401 error on the response regarding that the request was not authenticated. I'm just wondering how would I use the API Key for this instance.

In JSON i am passing:

{ "Email Address": "test@test.com", "Name": "Test" }

Im passing this through by C#

using (var client = new HttpClient())
  {
    var response = await client.PostAsync("https://api.createsend.com/api/v3.1/subscribers/LISTID.json", new StringContent(senderInfo, Encoding.UTF8, "application/json"));
  }

Is there something I'm meant to be passing through here?


Solution

  • Seems i was missing out the header for this response