端点 - https://data.geoiq.io/dataapis/v1.0/covid/locationcheck
{“键”:字符串,“纬度”:数组}
[在此处输入图片描述][1]
如何在 Flutter [1] 中使用这种格式从 API 获取数据:https ://i.stack.imgur.com/V6hVH.png
端点 - https://data.geoiq.io/dataapis/v1.0/covid/locationcheck
{“键”:字符串,“纬度”:数组}
[在此处输入图片描述][1]
如何在 Flutter [1] 中使用这种格式从 API 获取数据:https ://i.stack.imgur.com/V6hVH.png
基本上,您的 API 端点正在请求正文。
在颤振中,你可以使用包http: ^0.12.1
import 'package:http/http.dart' as http;
final api = 'https://data.geoiq.io/dataapis/v1.0/covid/locationcheck';
final response = http.post(api, body: { "key": string, "latlngs": array });
如果 API 端点需要身份验证令牌。例如 Bearer 令牌然后你可以使用
final token = 'YOUR TOKEN';
final response = http.post(api, body: { "key": string, "latlngs": array }, headers: {
'Authorization': 'Bearer $token',
});
请在下面找到示例请求。
import json as js
import requests
body = {"latlngs": [
[
12.967444,
77.498775
],
[
14.656773,
77.627936
],
[
19.200027,
72.970519
],
[
12.962882,
77.543543
]],
"key": "Auth Key"}
headers = {'Content-Type': 'application/json'}
r = requests.post(url = "https://data.geoiq.io/dataapis/v1.0/covid/locationcheck", data = js.dumps(body), headers = headers)