The contact can not be opted in using 'ACTION_BY_OWNER'

SOLVED
Go to solution
Participant

The contact can not be opted in using 'ACTION_BY_OWNER'

I'm trying to add an email address to a list. It's my understanding you need the email address Id, and the list names, and then you PUT them to the server.

 

my C# code looks like:

            string endPoint = "https://api.constantcontact.com/v2/contacts/{0}?api_key={1}";

            //set the email address id and api key

             endPoint = string.Format(endPoint, id, apiKey);

 

            //set the headers
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(endPoint);
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "PUT";
            httpWebRequest.Headers.Add("Authorization", "Bearer " + accessToken);
            httpWebRequest.Headers.Add("Action-By", "ACTION_BY_VISITOR");

my json looks like:

{
 "lists": [
{
"id": "3"
},
{
"id": "4"
}

],
                        "email_addresses":
                        [
                            {
                                "status": "ACTIVE",
                                "opt_in_source": "ACTION_BY_VISITOR",
                                "email_address": "xxx@yyy.zzz"
                            }
                        ]
                }"

 

I'm always getting a 400 error back, with the error message of:

The contact can not be opted in using 'ACTION_BY_OWNER'

 

Any ideas what I'm doing wrong?

 

Obviously, the code is working correctly, as I'm getting a proper json response back. I'm just not getting the correct response.

 


 

Thanks!

1 ACCEPTED SOLUTION
Moderator

There's just one small error in your request format.  The action_by paramater is actually supposed to be a query parameter, not a header.  Definition and allowed values can be found here: http://developer.constantcontact.com/docs/contacts-api/contacts-resource.html?method=PUT

 

Hope this helps!

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

2 REPLIES 2
Moderator

There's just one small error in your request format.  The action_by paramater is actually supposed to be a query parameter, not a header.  Definition and allowed values can be found here: http://developer.constantcontact.com/docs/contacts-api/contacts-resource.html?method=PUT

 

Hope this helps!

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

Thanks!

 

Exactly what I was looking for!

Developer Portal

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

Visit Page