Gemini API Error Inquiry

Hey everyone, just wanted to share what worked for us. We were getting the exact same 417 (Expectation Failed) error across all our C#/.NET integrations (Revit and Word add-ins) whenever we sent larger payloads like documents or images.

We isolated the issue by testing with a minimal Python script, which worked perfectly. It turns out the error is heavily tied to the Expect: 100-continue header, which C#’s HttpClient automatically attaches to requests with larger bodies. It seems Google’s proxy/firewall infrastructure recently added a strict size filter that aggressively rejects this specific pre-flight check, instantly returning the 417 error without even reaching the LLM.

The Fix for C#/.NET: You just need to explicitly disable this header in your code before making the request, forcing the client to send the payload directly:

C#

// If using modern HttpClient:
httpClient.DefaultRequestHeaders.ExpectContinue = false;

// If using older .NET Framework (like VSTO or Revit Add-ins):
System.Net.ServicePointManager.Expect100Continue = false;

Once we disabled that header, our large text requests and file uploads started working perfectly again. Hope this helps anyone stuck on the same stack!