The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Another 400 error when creating a campaign.

Highlighted
Occasional Participant

Another 400 error when creating a campaign.

Hi,

  I am trying to create  new campaigns when saving a node in Drupal. I believe I have the proper XML but I keep getting a 400 error. Can you take a look at the text here: https://gist.github.com/anonymous/784d778772a4244ea65e and let me know what I can do to make this a successful response.

 

Mark

Tags (3)
13 REPLIES 13
Highlighted
Employee

Re: Another 400 error when creating a campaign.

Hi Mark,

 

After changing account-specific details, I got a 201 Created response with your XML.  That means the discrepancy must be with the verified email address, list ID (18), or username.  The most likely issue is that the email address you referenced in the replyto and fromemail nodes is not the 13th verified email address in the account.  

 

Here you can see how to obtain a list of verified email addresses in your account and their corresponding ID's.

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Established Member

Re: Another 400 error when creating a campaign.

Shannon,

  Thanks for the quick reply. I verified all of the things you have pointed out. I was able to get the verified emails as suggested, so the API key and username is correct, and the resulting search did show that the reply email and id are correct. Also I verifed that the list id is correct, and even tried different lists to no avail. 

 

  The program I have building this was working previously. I remember when we started this, we had to do something to allow this user (afpcmail) to generate campaigns through the API. Can we verify that this is still valid?

Highlighted
Employee

Re: Another 400 error when creating a campaign.

Hi,

 

That is strange.  What is the text response from our server accompanying the 400 response code?  Often those can be helpful in determining the issue.

 

Best Regards,

Shannon W.

API SUpport Specialist

Highlighted
Occasional Participant

Re: Another 400 error when creating a campaign.

The response body is FALSE, and the error code is 400. No other text was returned. Here's the curl_getinfo() of the request:

 

http_response_info (Array, 21 elements)

Highlighted
Employee

Re: Another 400 error when creating a campaign.

Hi,

 

I can see that we're providing you a 62 character failure response along with the 400 error in our response to your calls to our server, but sadly I can't see what it is.

 

Could you use a restclient to send the XML payload to us, and look at the response it generates?  I'm partial to browser plugin restclients, but any restclient should show you the full response back.

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: Another 400 error when creating a campaign.

Shannon,

  Is there some time we can get together on GoToMeeting or some other live chat? I am having a wierd issue with the RESTClient now and really need someone to hold my hand apparently. Please let me know.

 

mark

Highlighted
Employee

Re: Another 400 error when creating a campaign.

Hi Mark,

 

We can try to accommodate you but aren't able to guarantee phone calls.  Email webservices@constantcontact.com with a few dates and times that would work for you, and we will try to make it work.

 

Just a few basics, this is the information you should need in restclients:

 

URL (complete it): 

 

https://api.constantcontact.com/ws/customers/af...

 

 

Headers:  You'll need to choose between basic and OAuth2, which requires an access token.  If you don't have an access token, you should base64 encode this string, with your own credentials filled in: apiKey%username:password

 

Authorization: Basic your_base64_encoded_string
content-type: application/atom+xml

 

 If you already have an access token, you can use:

 

Authorization: Bearer access_token_value
content-type: application/atom+xml

 

 

Body:

Your XML

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: Another 400 error when creating a campaign.

Shannon,

  No need to set up a call as that was the perfect amount of hand holding (I forgot to prepend the API Key when logging into the RESTClient)

 

  So now I am seeing the full response and getting an Error400: Invalid or Missing <EmailContent>. However when I validate my XML, passes validation. Here's the gist of it

 

https://gist.github.com/anonymous/0e9abb203d77b4b7007d

 

As you can see, the EmailContent node is present. 

  

 

mark

Highlighted
Employee

Re: Another 400 error when creating a campaign.

Hi Mark,

 

I just had time to change the username, verified email address, and from/reply-to email address id in your sample XML to make it match my account settings, and I still got a 201 Created (success) message back.  That's of course perplexing that it didn't work for you.

 

What happens when you change your email content node to the following?

 

<EmailContent>&lt;html&gt;&lt;body&gt;Hello!&lt;/body&gt;&lt;/html&gt;</EmailContent>

 

 

Best Regards,

Shannon W.

API Support Specialist

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured