Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - ERROR : HTTP 405 Method not allowed

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);
  }

like image 722
hasib_ullah Avatar asked Sep 05 '25 03:09

hasib_ullah


1 Answers

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);
  }
like image 111
Torkel Velure Avatar answered Sep 07 '25 20:09

Torkel Velure