REST API error: "You must specify a apikey value", api v2.0

933 views
Skip to first unread message

Fergal Condron

unread,
Dec 5, 2013, 12:52:10 PM12/5/13
to mailchimp-...@googlegroups.com
Hi,
I am trying to create a segment via the REST api. Currently I can subscribe users with the REST API so I know I have the right API key and List id. I am posting data to:
and the data is:

{
"apikey":"xxxxxxxxxx-us3",
"id":"xxxxxxxxx",
"opts":{"type":"saved","name":"test club","segment_opts":{"match":"all","conditions": ["Club":"test club"] } }
}

with apikey and id obviously have the correct values instead of the x. The json package I am getting back is:

{
status: "error"
code: -100
name: "ValidationError"
error: "You must specify a apikey value"
}

What am I missing to make this work?
Thanks

Civvy

unread,
Dec 6, 2013, 11:14:55 AM12/6/13
to mailchimp-...@googlegroups.com
Hi Fergal,

Potentially there could be something causing the API key data to be passed incorrectly formatted or perhaps that variable is being used elsewhere.  Adding in some verbose error checking to be sure the variable isn't being overwritten elsewhere might help. Additionally, you'll want to check out your syntax for conditions against: http://apidocs.mailchimp.com/api/2.0/campaigns/segment-test.php

Fergal Condron

unread,
Dec 6, 2013, 11:24:03 AM12/6/13
to mailchimp-...@googlegroups.com
Hi Civvy,
thanks for the response. The data I posted about I'm sending in a REST client.  When it wasn't working in the code I put it into the client so I knew exactly what was being sent over.

Skype: Fergal.Condron
Website: http://fergalcondron.com


On 6 December 2013 16:14, Civvy <cfog...@rsglab.com> wrote:
Hi Fergal,

Potentially there could be something causing the API key data to be passed incorrectly formatted or perhaps that variable is being used elsewhere.  Adding in some verbose error checking to be sure the variable isn't being overwritten elsewhere might help. Additionally, you'll want to check out your syntax for conditions against: http://apidocs.mailchimp.com/api/2.0/campaigns/segment-test.php

--
You received this message because you are subscribed to the Google Groups "MailChimp API Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mailchimp-api-di...@googlegroups.com.
To post to this group, send email to mailchimp-...@googlegroups.com.
Visit this group at http://groups.google.com/group/mailchimp-api-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Civvy

unread,
Dec 6, 2013, 1:29:07 PM12/6/13
to mailchimp-...@googlegroups.com
Hi Fergal,

Looks like our documentation isn't 100% there. That will need to be sent over urlencoded, instead.  For example:

apikey=xxxxxxxxxx-us3&
id=xxxxxxxxx&
opts[type]=saved&
....

I've opened a ticket to get that documentation updated.  Thanks!

Civvy

unread,
Dec 6, 2013, 4:28:13 PM12/6/13
to mailchimp-...@googlegroups.com
Hi Fergal,

After some additional testing here, it looks like the issue is related to the conditions, which should follow the documentation mentioned before. I'm showing the following will work as expected:

"conditions": [
                {
                    "field": "CLUB",
                    "op": "eq",
                    "value": "test club"
                }


Fergal Condron

unread,
Dec 10, 2013, 5:10:51 AM12/10/13
to mailchimp-...@googlegroups.com
HI Civvy,
that got it working, I had the conditions wrong. Works great now.
Thank you for your help,
Fergal

Skype: Fergal.Condron
Website: http://fergalcondron.com


Reply all
Reply to author
Forward
0 new messages