You can use http flutter package
and your code may be like
//Declared default headers
Map<String, String> headers = {"Accept": "application/json"};
//Passing the url
Uri url = Uri.parse("https://dev.xyz.com/api/test");
// Make the request, make sure your function has a return type of future and add async keyword in order to use await :)
var response = await http.post(url,headers: {...headers,'Authorization':"Bearer 7462-3172-8773-3312-5819"},body:{"email": "test@example.net",
"password": "aabbccdd",
"Name": "John",
});
print(response.body);
in your case if your not using Bearer
as your auth keword You can remove the bear key word and use x-api-key
keyword
so sample will be like
//Declared default headers
Map<String, String> headers = {"Accept": "application/json"};
//Passing the url
Uri url = Uri.parse("https://dev.xyz.com/api/test");
// Make the request, make sure your function has a return type of future and add async keyword in order to use await :)
var response = await http.post(url,headers: {...headers,'Authorization':"x-api-key 7462-3172-8773-3312-5819"},body:{"email": "test@example.net",
"password": "aabbccdd",
"Name": "John",
});
print(response.body);