无法使用MailChimp API v3创建细分

时间:2015-09-29 16:23:35

标签: mailchimp mailchimp-api-v3.0

我正在使用“游乐场”来测试创建细分,但我一直在验证错误

我的要求:

{
    "name": "MyTest",
    "options": {
        "match": "any",
        "conditions": [
            {
                "field": "EMAIL",
                "op": "is",
                "value": "p001@mymaildomain.xxx"
            },
            {
                "field": "EMAIL",
                "op": "is",
                "value": "p002@mymaildomain.xxx"
            }
        ]
    }
}

回应是:

type: http://kb.mailchimp.com/api/error-docs/400-invalid-resource
title: Invalid Resource
status: 400
detail: The resource submitted could not be validated. For field-specific details, see the 'errors' array.
instance:
errors:
    0:
        field: options.conditions.item:0
        message: Data did not match any of the schemas described in anyOf.
    1:
        field: options.conditions.item:1
        message: Data did not match any of the schemas described in anyOf.

2 个答案:

答案 0 :(得分:7)

实际上JSON的格式应该如下:

{
    "name":"email based",
    "options":{
                "match": "any",
                "conditions":[
                                {
                                    "condition_type":"EmailAddress",
                                    "field":"merge0",
                                    "op":"is",
                                    "value":"p001@mymaildomain.xxx"
                                },
                                {
                                    "condition_type":"EmailAddress",
                                    "field":"merge0",
                                    "op":"is",
                                    "value":"p002@mymaildomain.xxx"
                                }
                ]
    }

答案 1 :(得分:1)

对于也遇到此问题的其他人,如果您没有为所有已定义的合并字段提供键/值,也会发生此问题。如果在传入合并字段时使用不同的大小写,也会发生这种情况。因此,如果您定义了以下合并字段,那么它们是否设置为必需:

年龄 性别

确保始终传递年龄和性别的键/值对,使用完全相同的情况。如果您只传入“Age = 25”或“age = 25”,而未传入“Gender =”,则会出现上述错误,因为它不是一个设计良好的API。