Apple pay. Response status code does not indicate success: 417 (Expectation Failed) RRS feed

  • Question

  • I'm trying to get "merchant session" from Apple Pay Sandbox but my code always returns an error "417 (Expectation Failed)". I tried different ways with WebRequestHandler, httpclient, different headers but result is the same.

    static void Main(string[] args)
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        ServicePointManager.Expect100Continue = false;
        using (var httpClient = GetSecureHttpClient())
            var jsonData = "{\"merchantIdentifier\" : \"\", \"domainName\" : \"\",  \"displayName\" : \"MySite\" }";
            using (var content = new StringContent(jsonData, Encoding.UTF8, "application/json"))
                    httpClient.DefaultRequestHeaders.ExpectContinue = false;
                    using (var response = httpClient.PostAsync("", content).Result)
                catch (Exception ex) { Console.WriteLine("Apple Pay Gateway error: " + ex.ToString()); }
    public static HttpClient GetSecureHttpClient()
        var handler = new WebRequestHandler();
        handler.ClientCertificates.Add(new X509Certificate2(("C:\\merchantid_certificate.p12"), "", X509KeyStorageFlags.MachineKeySet));  
        return new HttpClient(handler, true);

    Monday, November 27, 2017 1:36 PM

All replies

  • Hi Dmitry Playanitsa,

    Thank you for posting here.

    I try to test the code, but the WebRequestHandler return a compiler error. The type or namespace name 'WebRequestHandler' could not be found (are you missing a using directive or an assembly reference?)

    The link you provided is broken.

    Based on my search, you could try the code below to set the HTTP header.

    System.Net.ServicePointManager.Expect100Continue = false;

    For more details, you could refer to the following link.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, November 28, 2017 5:58 AM
  • Hi Wendy Zang,

     try to test the code, but the WebRequestHandler return a compiler error. 

    For using WebRequestHandler is needed reference to assembly System.Net.Http.WebRequest.

    System.Net.ServicePointManager.Expect100Continue = false;

    This code is already present in my code.

    This URL is Apple Pay Sandbox endpoint and use secure connection that uses Apple merchant certificate.

    Tuesday, November 28, 2017 12:55 PM