Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TROUBLESHOOTING.md section about fixing error 415 #463

Merged
merged 1 commit into from
Oct 11, 2017
Merged

Add TROUBLESHOOTING.md section about fixing error 415 #463

merged 1 commit into from
Oct 11, 2017

Conversation

AlbinoDrought
Copy link
Contributor

@AlbinoDrought AlbinoDrought commented Oct 11, 2017

Wasn't sure how to phrase it while keeping it simple.

Explanation of issue and fix

If you were to have a file like this:

.sendgrid: (notice the linebreak)

SG.**

and you used it like

$apiKey = file_get_contents('.sendgrid');
$sendgrid = new \SendGrid($apiKey);
$sendgrid->client->mail()->send()->post($message);

The raw HTTP request, sent by curl, would look like: (notice the linebreak)

POST /v3/mail/send
Host: api.sendgrid.com
Authorization: Bearer SG.**

User-Agent: sendgrid/*;php
Accept: application/json
Content-Type: application/json

This causes all the headers after the Authorization header to be treated as the message body and effectively ignored. A simple pass through trim will fix this: $apiKey = trim($apiKey);

(would be simple to shove a trim in lib/SendGrid.php as well, assuming valid api keys have no excess whitespace)

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Oct 11, 2017
@SendGridDX
Copy link

SendGridDX commented Oct 11, 2017

CLA assistant check
All committers have signed the CLA.

@thinkingserious thinkingserious added difficulty: easy fix is easy in difficulty hacktoberfest labels Oct 11, 2017
@thinkingserious thinkingserious merged commit 72daaf7 into sendgrid:master Oct 11, 2017
@thinkingserious
Copy link
Contributor

Hello @AlbinoDrought,

Thanks again for the PR!

We want to show our appreciation by sending you some swag. Could you please fill out this form so we can send it to you? Thanks!

Team SendGrid DX

@mbernier
Copy link

If you are interested, we would love the opportunity to talk to you about Hacktoberfest and our API libraries.

Our agenda would be: Explore what you liked and is there anything we can do to improve?

You can grab a time on my calendar that works for you and we can have a chat on Google Hangout or Skype. If you prefer, you can email me using my GitHub username at my company’s domain.

Thank you so much,

Matt Bernier - @mbernier - SendGrid Developer Experience Product Manager
Elmer Thomas - @thinkingserious - SendGrid Developer Experience Engineer
@sendgrid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy fix is easy in difficulty status: code review request requesting a community code review or review from Twilio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants