问题
Im trying to make a http-request to Filemaker with Flutter(package:http/http.dart)
I can get the token normally, but if i try the make an _find request to Filemaker it always get's rejected(400 Bad Request) without any message. In Postman I can do the exact same request without issue!
var body = { "query":[{
"loginName": "==testUser@test.com"
}]};
Response response = await post(url,
headers: {
HttpHeaders.authorizationHeader: 'Bearer $token',
HttpHeaders.contentTypeHeader: 'application/json'},
body: json.encode(body));
回答1:
Found it: Dart http adds: content-type: application/json; charset=utf-8
And Filemaker rejects this.. But now is the question why does Filemaker API rejects such an API Call?
回答2:
SOLVED.
I was able to access one user in a FileMaker layout using Dio.
Dio dio = Dio();
dio.options.headers['content-Type'] = 'application/json';
dio.options.headers["authorization"] = "Bearer ${token}";
Response recordResponse;
recordResponse = await dio.post(
findUrl,
options: Options(followRedirects: false, validateStatus: (status)
{return status < 500;}),
data: { "query":
[{
"username": "=Jake",
"password": "=password"
}]
}
);
来源:https://stackoverflow.com/questions/61453322/flutter-filemaker-api-find-request