cancel
Showing results for 
Search instead for 
Did you mean: 

Schedule Email Campaign

Occasional Contributor

Schedule Email Campaign

I need a serious help.
Need help on scheduling campaign using asp.net. 
I have already configured my constant contact account to use api and I was success on using other api such as:

1. Retrieve Contact

2. AddContact

3. Read/Write ContactList

..

I was trying to schedule campaign and to do that I used HttpClient. I know have correct json data to post it. But when I make api call it always return Error:400, BadRequest.
My asp.net code looks like as below:

 

String jsonData = "{\"scheduled_date\":" + "\"2017-12-09T12:34:59Z\"}";
string requestPath = "emailmarketing/campaigns/"+id+"/schedules" + api;
string jsonContact = jsonData;
StringContent content = new StringContent(jsonContact, UnicodeEncoding.UTF8, "application/json");
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

HttpClient client = new HttpClient();
client.BaseAddress = new Uri(baseAddress); //baseAddress = https://api.constantcontact.com/v2/
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
var response = client.PostAsync(requestPath, content).Result;

 

I am not sure whats going wrong in the code it always sends Error:400. Is there any other alternative to achieve it.

 

Thanks in advance.

2 REPLIES
Moderator

Re: Schedule Email Campaign

Hello,

 

There are a few different things that can cause a 400 error. What is the error response message that is being returned with the error code 400? For example, "Property was found but is not permitted at this location" or "Unable to parse JSON payload"

 

These will be key to determining why your call is being rejected.

 

Regards,
David B.
Tier II API Support Engineer

Highlighted
Occasional Contributor

Re: Schedule Email Campaign

Thanks for the response. I was able to fix the error. 

Still need help?
You can post a new message in the Community or find us on Twitter Mon-Fri 8am - 8pm ET. We've got real people waiting to help you out. Click below to start a conversation!