Announcing our brand new Campaign Builder!

Error 400 received when making post method call

Campaign Contributor
0 Votes

Few mins back I was trying to make api post method request thru MVC5 Application


My request body was like such below:

"{\"scheduled_date\" : \"2017-12-01T17:50:31Z\"}"


and I received an error like below:


{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
Connection: keep-alive
Date: Fri, 01 Dec 2017 17:48:18 GMT
Server: Apache
Content-Length: 115
Content-Type: application/json; charset=UTF-8


I could not understand what mistake did I made, would any one suggest me whats going wrong there


0 Votes


Thank you for reaching out to Constant Contact API Support.

I see you are escaping the "s in your request data and also putting the whole thing in quotes. Are you setting this as a JSON string, and is it including your escape slashes and/or the quotes around the {}s? The contents of your data when received by Constant Contact's API should look like:


{"scheduled_date" : "2017-12-01T17:50:31Z"}


David B.
Tier II API Support Engineer

Campaign Contributor
0 Votes

I am setting this as json string. Even though still sending me same error.

I would like you to share my code which make a api call to schedule email.
My code looks like below:


DateTime dt = System.DateTime.Now.AddMinutes(10);
string dateISO = dt.ToString("yyyy-MM-ddTHH:mm:ssZ");

Models.schedule_campaign schedule = new Models.schedule_campaign();
schedule.scheduled_date = dateISO;
string requestPath = "emailmarketing/campaigns/"+id+"/schedules" + api;
string jsonContact = Newtonsoft.Json.JsonConvert.SerializeObject(schedule);
var content = new StringContent(jsonContact);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = HttpClient.PostAsync(requestPath, content).Result;


Where schedule is my model and is defined as:

public class schedule_campaign
public string scheduled_date { get; set; }


Developer Portal

View API documentation, code samples, get your API key.

Visit Page


API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up

How confident are you about the effectiveness of your current marketing strategy?

Top Choice: Not confident at all (76%)