1
我向the following resource發送POST
請求並獲得400.我瞭解what the error means,但仍然不確定爲什麼我在GET
請求同一資源時發生此問題。向MailChimp列表添加成員時的錯誤請求
/lists/{list_id}/members
下面是代碼的exerpt:
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', // <-- Drop in a GET here and it works, other than it's not the behavior I need.
env('MAILCHIMP_API_URL') . 'lists/' . env('MAILCHIMP_LIST_KEY') . '/members',
[
'auth' => ['app', env('MAILCHIMP_API_KEY')],
'query' => [
'email_address' => '[email protected]',
'email_type' => 'html',
'status' => 'subscribed',
]
]);
dd($response->getStatusCode());
響應
Client error: `POST https://XXXX.api.mailchimp.com/3.0/lists/XXXX/members?email_address=donnie%40test.com&email_type=html&status=subscribed`
resulted in a `400 Bad Request`
response: {
"type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title": "Invalid Resource",
"status": 400,
"detail": "The resource submitted could not be validated. For field-specific details, see the 'errors' array.",
"instance": "f32e7076-b970-4f5c-82c6-eec5875e83b4",
"errors": [{
"field": "",
"message": "Schema describes object, NULL found instead"
}]
}
您能否顯示整個響應?這通常發生在用戶已經在列表中(可能取消訂閱)。 –
該回復已添加到帖子中。 – Donnie
你能解決格式嗎?我正在尋找響應中的'detail'索引。 –