Paypal REST api call works from cURL but not from C# code

前端 未结 4 1565
旧时难觅i
旧时难觅i 2021-02-09 01:12

I\'m trying to call Paypal api from my code. I set up the sandbox account and it works when I use curl but my code isn\'t working the same way, returning 401 Unauthorized instea

4条回答
  •  轮回少年
    2021-02-09 01:53

    Paypal has deprecated TLS 1.1, and only accepts 1.2 now. Unfortunately .NET (prior to version 4.7) uses 1.1 by default, unless you configure it otherwise.

    You can turn on TLS 1.2 with this line. I recomend placing it Application_Start or global.asax.

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    

提交回复
热议问题