sendgrid-php
sendgrid-php copied to clipboard
Content-Type should be application/json
Using an API key with a newline at the end will make SendGrid respond with the error "Content-Type should be application/json".
Since this repo is for the PHP SDK specifically, it might not be the best place for it, but since I've used this package I thought I post the issue here.
This is strictly speaking a user-error, but I think SendGrid should give a better error, saying that the it is the API key that's wrong.
Maybe it could just trim whitespaces? I'm no security expert, so not sure about that.
For more background, this happened to me because I was saving the key as base64 encoded string in an env var for later use (using k8s secrets), and the command I used was:
echo 'myapikey' | base64
:point_up: What I missed here is that "echo" will add a newline at the end by default, so the correct way to do this is:
echo -n 'myapikey' | base64
Even if this is not fixed I hope that I help someone in the future googling, because it took me a while to finally find this by accident: http://jlsegurosystem.com.br/vendor/sendgrid/sendgrid/TROUBLESHOOTING.md
Thank you for reporting this @ZeeCoder!
This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.
With best regards,
Elmer