Auth for Rest API issues

Hello,

 

I have recently started to recieve the error "The underlying connection was closed: An unexpected error occurred on a send." when trying to authenticate with the REST Api. This code worked fine last week and now it's failing. I am using RestSharp/C#, can anyone see what my issue is? I don't believe that I have changed anything....

 

 

CommunityMember123802_0-1596741448071.png

 

Answers

  • Hi,

    Are you using 2.0 API or 1.3?

    Regards,
    Anirudh
  • I am using 2.0. Here are is the base url and the auth url that i am using. 

     

    https://auth.anaplan.com/token/authenticate

    https://api.anaplan.com/2/0/

  • Hi,

     

    did you try to login directly in the Anaplan home page with that user/pass?, maybe it expire 

     

    Regards

  • Sadly, the account is fine. And yes, I did check. That is why this is so frustrating.

  • Did you find a solution?

     

    I'm having a similar issue. using api 2.0

    Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send. 

     

    Script works from UI but not when called from Informatica.

     

    Research leaning toward tls issue, no success with the suggestions around forcing tls version.

  • Yes, I did.  Check the project that is calling the Anaplan REST api and make sure that compiling for at least .NET 4.6(?). The issue is with the TLS version, <4.6 is using the older TLS version. It's not a verbose error, and needs some digging to find the root cause. 

  • My issue solved. I had to add -Proxy to the failing Invoke-WebRequest statement. Due to this being a service account, policy will not allow updating the IE settings directly.
  • Try something like this at the beginning of your method:

     

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;

     

    This appears to be an issue with the .NET web request rather than an Anaplan thing.