flutter - Android 上的 Amplify.API.get 问题(它适用于 iOS!)#446
问题描述
如果提供的路径变量包含特殊字符,则错误 Amplify.API.get 在 Android 和 iOS 中调用不同的路径!
重现:
Future getUser(String username) async {
String path = '/users/$username';
print(path);
RestOptions restOptions = RestOptions(path: path);
try {
RestOperation restOperation = Amplify.API.get(restOptions: restOptions);
RestResponse response = await restOperation.response;
String responseBody = new String.fromCharCodes(response.data);
var jsonResponse = convert.jsonDecode(responseBody);
User user;
if (jsonResponse != null) {
user = User.fromJson(jsonResponse);
}
return user;
} on ApiException catch (e) {
print('GET call failed: $e');
}
}
如果用户名变量包含特殊字符,则在 iOS 和 Android 中调用 2 个不同的路径。
示例:如果用户名等于 'name.surname+test1@gmail.com':
- 在 iOS 模拟器中,它正确调用了 URL:https://hostname/users/name.surname+test1@gmail.com
- 在 Android 模拟器中,它调用了错误的路径:https://hostname/users/name.surname%20test1@gmail.com
平台 此问题可在:[X] Android [] iOS 中重现
解决方案
推荐阅读
- mysql - 用于简单相关性排名的 SQL
- vb.net - 使用 PrintForm 功能横向打印表单
- python-3.x - 如何标记语料库以进行词形还原?
- javascript - 将一组函数覆盖为 Promise
- javascript - 用于 javascript 代理的 Chrome Devtools 格式化程序
- error-handling - 如何使用 VBA 为表单、报表和数据表设置条件格式
- java - 编写方法重载的最佳方法是什么?
- sql-server - 具有默认为默认约束值的参数的存储过程
- api - 为什么 Clio Users 端点总是返回一个 null 的联系人对象?
- django - 在上传到 s3 之前压缩图像的最佳选择