首页 > 解决方案 > 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':

平台 此问题可在:[X] Android [] iOS 中重现

标签: flutterdartamplify

解决方案


推荐阅读