postRequest method
dynamic
postRequest({})
Implementation
postRequest(
{required body,
required String request,
required String baseUrl,
required String consumerKey,
required String consumerSecret}) async {
final response = await http.post(
Uri.parse(baseUrl + request),
headers: {
'Content-Type': 'application/json',
'Authorization':
'Basic ${base64Encode(utf8.encode('$consumerKey:$consumerSecret'))}',
},
body: body,
);
// Check if the request was successful (status code 201)
if (response.statusCode == 201) {
return response;
} else {
throw Exception(
'Error -: Failed to Complete Request : ${json.decode(response.body)}');
}
}