It seems that $response->headers() does not return an associative array, although https://github.com/sendgrid/sendgrid-php/issues/361 and https://github.com/sendgrid/php-http-client/pull/19 say it should
How can we reliably get that value?
(The docs say "When using the Event Webhook, it's a best practice to store your X-Message-ID." so we'll do that, just need to know how to get it. Thanks!)
Hi @KayakinKoder, thank you for your report.
Can you provide the response headers output that you get?
Thanks.
@peter279k yes, thanks
array (
0 => 'HTTP/1.1 202 Accepted',
1 => 'Server: nginx',
2 => 'Date: Thu, 15 Nov 2018 17:28:20 GMT',
3 => 'Content-Type: text/plain; charset=utf-8',
4 => 'Content-Length: 0',
5 => 'Connection: keep-alive',
6 => 'X-Message-Id: v8TRYFfWRu2BOIOCqlvX_w',
7 => 'Access-Control-Allow-Origin: https://sendgrid.api-docs.io',
8 => 'Access-Control-Allow-Methods: POST',
9 => 'Access-Control-Allow-Headers: Authorization, Content-Type, On-behalf-of, x-sg-elas-acl',
10 => 'Access-Control-Max-Age: 600',
11 => 'X-No-CORS-Reason: https://sendgrid.com/docs/Classroom/Basics/API/cors.html',
12 => '',
13 => '',
)
@KayakinKoder, thank you for your reply.
According to this PR, it seems that the headers method has the optional argument and determine the response headers array is associative or normal.
Can you use var_dump($response->headers(true)); then try again? Thanks.
Ah I missed that, thanks yes that works
Thanks for helping out @peter279k!
Most helpful comment
Ah I missed that, thanks yes that works