EDIT: Posted fix in comments below- was using Postman incorrectly
The call works successfully in postman, but fails from my flutter application. In postman, I include the following key, value in "Body"
key: dirty
Value:
{"Roster":[],"Athlete":[{"AthleteID":"cac8396a-d83e-4c0c-b8b4-97a0b3fdd65a","FirstName":"Dom","LastName":"Aluise","Alias":"","Height":null,"Weight":null,"BDay":null,"AccountID":"4771ac0d-2959-4abd-9ae1-52e29b6016e6","Updated":1632947536476,"Dirty":1},"Trial":[]}
However the call fails when trying to make the call with Dart, once it reaches my flask API, the quotation marks inside "value" all become single quotes, and thus doing "Json.loads" on the "dirty" argument fails. Here is how I call the API from flutter:
Uri uri = Uri.parse('https://' + apiUrl + '/api/v1/' + endpoint);
print(queryParameters);
//final uri = Uri.https(apiUrl, '/api/v1/$endpoint', queryParameters);
final response = await http.post(uri,
headers: {
HttpHeaders.authorizationHeader: 'bearer $accessToken',
HttpHeaders.contentTypeHeader: 'application/json',
},
body: json.encode(queryParameters));
Where queryParameters is a map<String, dynamic> like: {"dirty" : {"Roster": [], .....} containing all the above value data.
What do I need to do instead to make sure that the body is being successfully transferred to the flask API? In python, my argument is defined as:
self.parser.add_argument("dirty", type=str, help="JSON encoded dirty records from local database")
I assume it is a Flutter problem because the request works through postman. Thank you