Showing results for 
Search instead for 
Did you mean: 
Constant Contact wants to help you succeed! We’re celebrating our professional service programs on the Constant Contact Community this month and you have a chance to try one of the services for free! Learn more.

Error 400 received when making post method call

Occasional Contributor

Error 400 received when making post method call

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



Re: Error 400 received when making post method call


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

Occasional Contributor

Re: Error 400 received when making post method call

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; }