I have to make a http request for an api
base url is: https://learning-objects-v2.p.rapidapi.com
GET /search-provider?keywords=Python&lang=en&provider=Coursera&sort=popularity&model=strict&max=20&page=2
X-Rapidapi-Host: learning-objects-v2.p.rapidapi.com
X-Rapidapi-Key: key
Host: learning-objects-v2.p.rapidapi.com
what I have tried
var client = http.Client();
var result = null;
final response = await client.get(
Uri.parse(
'https://learning-objects-v2.p.rapidapi.com/search-provider?keywords=$keyword&lang=en&provider=Coursera&sort=popularity&model=strict&max=20&page=2'),
// Send authorization headers to the backend.
headers: {
HttpHeaders.acceptHeader:
'key',
},
);
but this does not seem to work properly can someone help me please
CodePudding user response:
Try
Map<String, String> requestHeaders = {
'Content-type': 'application/json',
'Accept': 'application/json',
'Authorization': '<Your token>'
};