Flutter Filemaker API _find request

我的未来我决定 提交于 2020-08-10 19:12:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!