-
Notifications
You must be signed in to change notification settings - Fork 587
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
Send mail fails with BadRequest when apostrophe used in sender name #232
Comments
Hello @RyanONeill1970, Thanks for bringing this issue to our attention. We will take a look and find out where the fix should happen. |
I've been playing with this and can confirm that there is an error in the v3 API endpoint https://api.sendgrid.com/v3/mail/send. There may be other errors in the client, but I am bypassing that for this test. I have been posting the following JSON which results in a bad request response code. Removing the apostrophe in the senders surname makes it work.
The raw response from the API endpoint;
A not great workaround is to use a back tick in place of the apostrophe. |
Hi @RyanONeill1970, I believe the "Bad Request" in this case is because the subject is inside of the personalizations block, instead do:
When I try this via a cURL request the apostrophe is handled correctly, meaning the issue is not with the api call. I will now test the library to see where the error is. How were you trying the call outside of the library? Here is how I did it:
Where the post.json file has the above content. |
The issue is that the single quote ( ' ) isn't support in the Content object either during my testing. The workaround for this issue is that you can use the ` character and your code should work. To be clear, that is the character that is under the tilde character on a US Keyboard layout. |
The following (slightly modified from the Readme example) also generates BadRequest: |
I have a fix deploying today @RyanONeill1970 and @RayHAz, thanks for hanging in there with me :) |
Here is the fix: https://www.nuget.org/packages/Sendgrid/7.0.3 Thanks again! |
Hello guys, I am also facing the similar problem while using apostrophe in the fromname field in one of our php project. When I use the text like "Webner's" in fromname, it just shows "Webners" as a sender name in the email sent. I am using both the methods (using curl-post request and using php library of sendgrid), but I am facing the same problem with both of them. Please provide any solution how should I do this. Thanks in advance. Manju Kashyap |
Hello @manju-kk, Would you mind opening a new issue with the following information?
Thanks! |
If you are passing not string value then SendGrid will give you 👇 {"errors":[{"message":"Bad Request","field":null,"help":null}]} Convert your all non-string value to string before sending to the template file. Happy Coding 😊 |
Hello @vivekbhandari279 , {"errors":[{"message":"Bad Request","field":null,"help":null}]}curl: (3) URL using bad/illegal format or missing URL |
On line 26 of Example.cs in the demonstration project for betav3 we have the sender email address.
If we add a name, it mostly works unless you happen to have a surname with an apostrophe in.
For example, these work;
Email from = new Email("[email protected]");
Email from = new Email("[email protected]". "Ryan");
The following result in a BadRequest status code.
Email from = new Email("[email protected]", "Ryan O'Neill");
Email from = new Email("[email protected]", "Ryan O\'Neill");
The output from the console test app is;
I'm not certain where the issue is, in the client wrapper or at the server. I suspect both because I have been able to bypass the client and directly post to the server, generating an email by escaping the apostrophe but it comes out as a double apostrophe.
The text was updated successfully, but these errors were encountered: