doPostRequest method
Send a http post request to the specified uri. The data / body of the request has to be provided as map. (key, value) The result of the request will be returned as string.
addCredentialsToBody
should be only use for Robotoff,
See: https://github.com/openfoodfacts/openfoodfacts-dart/issues/553#issuecomment-1269810032
When using addCredentialsToBody
a User or globalUser needed, blocks QueryType.TEST authentication
Implementation
Future<http.Response> doPostRequest(
Uri uri,
Map<String, String> body,
User? user, {
QueryType? queryType,
required bool addCredentialsToBody,
bool addCredentialsToHeader = false,
}) async {
if (addCredentialsToBody) {
if (user != null) {
body.addAll(user.toData());
}
}
http.Response response = await http.post(
uri,
headers: _buildHeaders(
user: user,
isTestModeActive:
OpenFoodAPIConfiguration.getQueryType(queryType) != QueryType.PROD,
addCredentialsToHeader: addCredentialsToHeader,
),
body: addUserAgentParameters(body),
);
return response;
}