I'm making a website in Flutter Web.
Using Dio I want to access an API (made in Go by me) that is on my server, with HTTPS and an assigned domain.
GET requests originated by the website work wonderfully. PUT and POST requests return 404, even though the endpoint exists.
Testing the server requests with Postman or Imnsonia everything works, but requests received from the site there is no way.
The site is hosted on the same server by Caddy, and I have a reverse_proxy that redirects the domain to the API internally to the server.
Can you catch the problem like that. Also in browser like Chrome you may see the error log in console . As you can see i fetch the data with model so my suggestion you may wanna control your model. Especially the types. num => double, float ,int kind of ... You may change everything to string and put into a string model to determine is it working or not.
getError(String ref) async {
try {
isDataLoading(true);
final dio = Dio();
final response = await dio.getUri(
Uri.tryParse('${ref}***********')!,
);
if (response.statusCode == 200) {
response.data.forEach((element) async {
subProductCategori.add(altgrupModel.fromJson(element));
int a = altgrupModel.fromJson(element).aLTGRUPREF!;
});
} else {
print("StatusCode Error");
}
} catch (e) {
printError(info: e.toString());
} finally {
isDataLoading(false);
}
}