I'm trying to read json file through an API that was given to me by a client, but It's giving HTTP error 405 saying method not allowed. Can anyone please tell what I'm doing wrong?
This api request snippet was given to me :
curl 'http://finelistings.com/backend/apis/webbrands/' -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '{}' --compressed --insecure
Future<String> getData() async {
var response = await http.get(
Uri.encodeFull("http://finelistings.com/backend/apis/webbrands/"),
headers: {
"Accept": "application/json",
}
);
Map<String, String> data = jsonDecode(response.body);
print(data);
}
Method not allowed might refer to wrong request method.
Try using POST instead of GET, at least I got a response from that using the mentioned URL.
Future<String> getData() async {
var response = await http.post(
Uri.encodeFull("http://finelistings.com/backend/apis/webbrands/"),
headers: {
"Accept": "application/json",
}
);
Map<String, dynamic> data = jsonDecode(response.body);
print(data);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With