postRawApiRequest method

Future<String?> postRawApiRequest({
  1. required Uri uri,
  2. required Map<String, String> headers,
  3. Map<String, dynamic>? body,
})

Makes a raw POST request to the API.

uri - The URI to send the request to headers - The headers to include in the request body - Optional request body

Returns the raw response body as a string or null if the request fails.

Implementation

Future<String?> postRawApiRequest({
  required Uri uri,
  required Map<String, String> headers,
  Map<String, dynamic>? body,
}) async {
  final response = await http.post(
    uri,
    headers: headers,
    body: convert.jsonEncode(body),
  );
  if (response.statusCode == 200) {
    return response.body;
  } else {
    print('Request failed with status: ${response.statusCode}.');
  }
  return null;
}