我试图通过API将用户添加到列表中。但是,我收到了此错误:
{"errors":[{"code":"parsing_error","message":"JSON parsing error: The property '#/' of type Hash did not match one or more of the required schemas"}]}
这就是我发送的内容:{"subscribers":{"email":"me@gmail.com"}}
这是PHP代码:
$subscriberInfo = [
'subscribers' => array (
'email' => $email
)
];
$encoded = json_encode($subscriberInfo);
JSON的结构有问题吗?
答案 0 :(得分:2)
这不是文档中描述的格式。 subscribers
应该是一个数组,而不是一个对象:
$subscriberInfo = [
'subscribers' => [
['email' => $email]
]
];
$encoded = json_encode($subscriberInfo);