Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am facing "406 not acceptable nginx" error when I call send grid api

Tags:

c#

sendgrid

I am facing

"406 not acceptable nginx"

..error when I call send grid api

Sometimes it gives me json response perfect but after 2 3 minutes it gives me:

"406 not acceptable" error

We have been facing this error for 3 months. Please help us.

I used the below code in c#

HttpClient client1 = new HttpClient();   
client1.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
client1.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "authentication key");
client1.DefaultRequestHeaders.Add("on-behalf-of", "email id");
HttpResponseMessage response1 = client1.GetAsync("https://api.sendgrid.com/v3/senders").Result;
Response.Write(response1.Content.ReadAsStringAsync().Result);
like image 607
Dinesh Prajapati Avatar asked Nov 16 '25 00:11

Dinesh Prajapati


1 Answers

I worked through this issue with Sendgrid support and in my case it was concluded that this error corresponded with the request being issued from an IP address that was blocked by their security policy. If you are making these requests from a cloud function environment like Firebase or Lambda, where the IP address can change with each instance, this may be the reason. Their support team may be able to add IP addresses to their allow-list but a better solution may be to route your request through a dedicated IP address.

like image 107
ehed Avatar answered Nov 17 '25 18:11

ehed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!