417 Expectation Failed error

Published May 25 2021 01:24 PM 945 Views
Microsoft

417 status code refers to an issue with the Expect header in the request. The server was probably not able to meet the requirement in this header (RFC7231).

Nedim_0-1621974218455.jpeg

Solution

Collect a Fiddler trace and analyze the header. Do due diligence like probing when the issue started occurring, what was changed before, does it work in another server, etc.

 

In my case, the issue was caused by a missing forward slash (“/”) at the end of the CorsOrigin parameter in appsettings.json. Adding this solved the issue.

 

Note: System.Net.HttpWebRequest automatically adds “Expect: 100-Continue”‘ to requests (Reference). You may try removing it explicitly to solve this issue:

System.Net.ServicePointManager.Expect100Continue = false;

 

You can also remove this header through web.config:

<system.net>
    <settings>
        <servicePointManager expect100Continue="false" />
    </settings>
</system.net>

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2385251%22%20slang%3D%22en-US%22%3E417%20Expectation%20Failed%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2385251%22%20slang%3D%22en-US%22%3E%3CP%20data-unlink%3D%22true%22%3E417%20status%20code%20refers%20to%20an%20issue%20with%20the%26nbsp%3BExpect%20header%26nbsp%3Bin%20the%20request.%20The%20server%20was%20probably%20not%20able%20to%20meet%20the%20requirement%20in%20this%20header%20(RFC7231).%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Nedim_0-1621974218455.jpeg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F283670iD5BECCFD7403FA14%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Nedim_0-1621974218455.jpeg%22%20alt%3D%22Nedim_0-1621974218455.jpeg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-2033850737%22%20id%3D%22toc-hId-2033850738%22%3E%3CSTRONG%3ESolution%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CP%3ECollect%20a%20Fiddler%20trace%20and%20analyze%20the%20header.%20Do%20due%20diligence%20like%20probing%20when%20the%20issue%20started%20occurring%2C%20what%20was%20changed%20before%2C%20does%20it%20work%20in%20another%20server%2C%20etc.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20my%20case%2C%20the%20issue%20was%20caused%20by%20a%20missing%20forward%20slash%20(%E2%80%9C%2F%E2%80%9D)%20at%20the%20end%20of%20the%20CorsOrigin%20parameter%20in%20appsettings.json.%20Adding%20this%20solved%20the%20issue.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENote%3A%3C%2FSTRONG%3E%26nbsp%3BSystem.Net.HttpWebRequest%20automatically%20adds%20%E2%80%9CExpect%3A%20100-Continue%E2%80%9D%E2%80%98%20to%20requests%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fsystem.net.servicepointmanager.expect100continue%3Fredirectedfrom%3DMSDN%26amp%3Bview%3Dnet-5.0%23System_Net_ServicePointManager_Expect100Continue%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EReference%3C%2FA%3E).%20You%20may%20try%20removing%20it%20explicitly%20to%20solve%20this%20issue%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3ESystem.Net.ServicePointManager.Expect100Continue%20%3D%20false%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20remove%20this%20header%20through%20web.config%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%3CSYSTEM.NET%3E%0A%20%20%20%20%3CSETTINGS%3E%0A%20%20%20%20%20%20%20%20%3CSERVICEPOINTMANAGER%20expect100continue%3D%22false%22%3E%3C%2FSERVICEPOINTMANAGER%3E%0A%20%20%20%20%3C%2FSETTINGS%3E%0A%3C%2FSYSTEM.NET%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2385251%22%20slang%3D%22en-US%22%3E%3CP%3E417%20status%20code%20refers%20to%20an%20issue%20with%20the%26nbsp%3BExpect%20header%26nbsp%3Bin%20the%20request%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Co-Authors
Version history
Last update:
‎May 25 2021 01:24 PM
Updated by: