0

I am facing an issue related to retrofit. When I use HTTP then my API's are working fine but whenever I use HTTPS, some of the API's don't work and return 401; not the right data.

I don't understand what's happening here.

Samset
  • 109
  • 7
  • https generally requires some security configurations.Have you got them setup? – Vivek Mishra Aug 13 '18 at 06:04
  • which type configuration ?. I did change only base URL but nighter change anything – Samset Aug 13 '18 at 06:19
  • https://stackoverflow.com/questions/24624439/how-to-call-https-web-service-in-android. Check the link. It is generally related to ssl certificates – Vivek Mishra Aug 13 '18 at 06:21
  • I am not using SSL certificate in client side my server is already added SSL certificate but above link describes how to add client-side add SSL. – Samset Aug 13 '18 at 06:29
  • 1
    401 error code means "unauthorised". You are not passing the right credentials or parameters to your backend. Check your backend validation and change the parameters while passing according to the needs of backend. – emilpmp Aug 13 '18 at 07:06
  • I pass all required parameter and track with facebook stetho. If I test with postman then working fine but if I use API with my code then throw 401 unauthorize status code – Samset Aug 13 '18 at 07:21
  • emilpmp is right. This has nothing to to with https, unless your implementation depends on it, which it shouldn't – Tim Aug 13 '18 at 07:26
  • I usually encounter that error. To see your requests and responses, try to install OkHttpClient's Logging interceptor then add it on where you instantiated your OkHttpClient. In that way, you can see what's the content of your requests to the server then you could also modify it for the server to accept and for you to throw the correct requests that your web service ought to receive. – zekromWex Aug 13 '18 at 07:26
  • I am track API I send header data but the server is not found header data so i am not understood why not send retrofit header data to the server. But when I use HTTP then retrofit working fine. – Samset Aug 14 '18 at 14:19
  • @samset did you ever find the solution for this one? I have same issue – Mr. Jay Sep 28 '21 at 11:43
  • No, still facing same issue @Mr.Jay – Samset Nov 11 '21 at 14:09

0 Answers0