Hey guys, I’m trying to fetch the API using flutter/dart for a web App, but I got 400 error.
Future fetchData() async {
final response = await http.get(
Uri.parse("https://api.company-information.service.gov.uk/company/06500244"),
headers: {
HttpHeaders.authorizationHeader: "Basic ${apiKey}",
},
);
final jsonResponse = convert.json.decode(response.body);
if (response.statusCode == 200) {
print(jsonResponse.toString());
} else {
throw Exception(response.statusCode);
}
}
Any other information I need to pass other than apikey?
Thanks.