Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Basic Auth working in postman but it doesn't work on Flutter with dio even its same

I have a Basic Auth token. In postman its working as expected but when i try same thing with same header its not working on flutter dio. Why its not working ? How can i fix it ?

In Postman :

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

But when i try same thing in flutter with dio like :

 final Dio _basicAuthDio = Dio();
 String cred = "username:password";
String credEnc = utf8.fuse(base64).encode(cred);
_basicAuthDio.options = BaseOptions(
  baseUrl: "${ApiConstants.baseUrl}v2",
  headers: {HttpHeaders.contentTypeHeader: "application/json", "Authorization": "Basic $credEnc"},
);

enter image description here

Its always giving me 404 error. Even data is same,endpoint is same, header is same. Why its happening ? How can i solve it ?

>Solution :

Make sure you didn’t forgot api/v2/… part. Is the same url showing up in request object details?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading