-1

how convert this command curl $ curl -u app_id:app_secret -X GET {api}/auth_username to http method to use it in flutter

and the result:

  "meta": {
    "page": 1,
    "limit": 10,
    "count": 3
  },
  "data": [
    {
      "username": "api_user2"
    },
    {
      "username": "api_user1"
    },
    {
      "username": "test"
    }
  ],
  "code": 0
}

please help thanks

3

2 Answers 2

0

if you are using http package , you request url become like this

String credentials = "$app_id:$app_secret";
var bytes = utf8.encode(credentials);
var encodedHead = base64.encode(bytes);

CLient().get(Uri.parse('https://$api/auth_username'),headers :
 "Authorization: Basic $encodedHead"
)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks i will try that
0
  1. Goto your postman
  2. Click on Import Button Text & Paste your curl & Click Continue
  3. Then Click Code just below (Send / Save) Button

You will see the Generated Code Snippets

1 Comment

Thanks i will try that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.