HTTP POST Returns Error: 417 “Expectation Failed.”

后端 未结 10 868
离开以前
离开以前 2020-11-28 18:04

When I try to POST to a URL it results in the following exception:

The remote server returned an error: (417) Expectation Failed.

相关标签:
10条回答
  • 2020-11-28 18:37

    Check that your network connection isn't redirecting.

    I had this issue when on the wrong wifi and any web request was redirecting to a corporate login page.

    0 讨论(0)
  • 2020-11-28 18:38

    Another way -

    Add these lines to your application config file configuration section:

    <system.net>
        <settings>
            <servicePointManager expect100Continue="false" />
        </settings>
    </system.net>
    
    0 讨论(0)
  • 2020-11-28 18:39

    System.Net.HttpWebRequest adds the header 'HTTP header "Expect: 100-Continue"' to every request unless you explicitly ask it not to by setting this static property to false:

    System.Net.ServicePointManager.Expect100Continue = false;
    

    Some servers choke on that header and send back the 417 error you're seeing.

    Give that a shot.

    0 讨论(0)
  • 2020-11-28 18:39

    For Powershell it is

    [System.Net.ServicePointManager]::Expect100Continue = $false
    
    0 讨论(0)
提交回复
热议问题