I have a code where I use http package in flutter to post request from a Fake API, which I found using the website mocki.io. The problem is that whenever I put the correct data, it keeps giving me response.statusCode = 405.
http_service.dart (post request)
class HttpService {
static const _loginUrl = 'https://mocki.io/v1/d4867d8b-b5d5-4a48-a4ab-79131b5809b8';
static login(cpf, password, context) async {
Map<String, String> request = {"name": cpf, "city": password};
final response = await http.post(
Uri.parse(_loginUrl),
body: jsonEncode(request),
);
if (response.statusCode == 200) {
await Navigator.push(
context, MaterialPageRoute(builder: (context) => HomeScreen()));
} else {
await EasyLoading.showError(
"Error Code : ${response.statusCode.toString()} $cpf $password");
}
}
}
Inserting the data, according to the fake mocki API: enter image description here Error presented: enter image description here
I would like some help with using Rest API, Flutter and Flask =D. I'll be grateful to those who can send me links about that subject (courses, videos etc).
I tried reading lots of blogs about that same subject, none helped. As I'm novice to that area. =(