postJson static method
Implementation
static Future<Map<String, dynamic>> postJson(String url, Object body) async {
var headers = {'Content-Type': "application/json"};
var requestUrl = _mBaseUrl + url;
if (getSessionToken() != null) { headers["Authorization"] = "Bearer ${getSessionToken()}"; }
if (getAppId() != null) { headers["app-id"] = getAppId()!; }
try {
final response = await Dio().post(requestUrl,
options: Options(headers: headers, receiveDataWhenStatusError: true),
data: jsonEncode(body));
if (response.statusCode! >= 200 && response.statusCode! < 300) {
return response.data;
}
throw HttpUtil.makeTPException(response);
} on DioException catch (e) {
throw HttpUtil.makeTPException(e.response);
} catch(e){
rethrow;
}
}