I'm trying to fetch the data from DynamoDB using API Gateway + Lambda from flutter APP.
I'm using AWS Amplify plugins for the same
Link to AWS docs: https://docs.amplify.aws/lib/restapi/getting-started/q/platform/flutter#initialize-amplify-api
When authorization is set to None I'm able to fetch the data successfully
But when I set the authorization type to IAM for API gateway I'm facing the below mentioned error.
post call failed: ApiException(message: The HTTP response status code is [403]., recoverySuggestion:
I/flutter ( 6554): The metadata associated with the response is contained in the HTTPURLResponse.
I/flutter ( 6554): For more information on HTTP status codes, take a look at
I/flutter ( 6554): https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
I/flutter ( 6554): , underlyingException: null)
My Code:
Future<List<ChapterData>> getChapters(String subjectID) async {
String postRequest = '{\"subject_id\":\"' + subjectID + '\"}';
print(postRequest);
try {
RestOptions options = RestOptions(
path: "/getChapterList",
body: Uint8List.fromList(postRequest.codeUnits),
apiName: "getChapterList");
RestOperation restOperation = Amplify.API.post(restOptions: options);
RestResponse response = await restOperation.response;
var chapterData = ChapterData.fromJson(
json.decode(new String.fromCharCodes(response.data)));
return chapterData;
} on ApiException catch (e) {
print('post call failed: $e');
}
}
}
Is there anything I missed adding to the post request since it is failing only when I set the authorization type to IAM.
I didn't find any documentation related to this for flutter/dart. Also, I'm new to flutter
Thanks in Advance