2 Replies Latest reply on Nov 3, 2016 5:23 PM by akenyon

    Error 401 not authorize



      i am working on a .net application with visual Studio 2015 
      I have a problem with piwebapi. When i try to call the address, in my source code, i receive an error which said : error 401 not authorize.

      but when i take the same link and i copy past in my chrome browser, the piwebapi works normally. in the two case, i am logged with the same account.

      furthermore, i don't know where i can find logs about piwebapi

      can you help me please ?

      best regards hay,


        • Re: Error 401 not authorize

          Hello Romain,


          Any chance that you previously accepted a warning in your browser telling that navigation (https) is not secure?



          I am not sure what technology you are using for your devs but you may need to change some settings during you developments to allow working with the self-signed SSL certificate generated by PI Web API:


          c# - Allowing Untrusted SSL Certificates with HttpClient - Stack Overflow


          The other (better options) is to add the SSL certificate from PI Web API server into your trusted store.

          the full how-to is available on this video:Setting up PI Web API for a Development Project - from 4:43

          (Thanks Daphne Ng ;o) )


          Hope this helps,

          3 of 3 people found this helpful
          • Re: Error 401 not authorize

            Are you adding the Authentication headers to your request? In the browser when you first visited the piwebapi address you may have been prompted for credentials. The browser identified the site as requiring authentication, prompted the user, and now has your credentials cached. The browser will take care of everything for you, up until the cached credentials expire or are cleaned up. In your C# app you need to take care of this process manually by adding the authentication headers manually.


            Additionally, as Patrice Thivierge mentioned, you'll need to setup a certificate for your web api or set your http client to ignore certificate errors.