post abstract method

Future<JSON?> post({
  1. required String host,
  2. String? path,
  3. Map<String, String>? queryParameters,
  4. Map<String, String>? headers,
  5. JSON? body,
  6. bool isHttps = true,
})

Posts JSON body to the HTTP endpoint using thehost, path, queryParameters and headers using HTTPS if isHttps.

If the response body is not a Map<String, dynamic>, the body will be wrapped in a hashmap in a field with the key "data".

The HTTP request/response properties are added to the JSON with the following keys:

  • the "_%path" is the endpoint path string;
  • the "_%status" is the response statusCode;
  • the "_%query" is a hashmap containing the request query parameters;
  • the "_%headers" is a hashmap containing the request headers;

If an error occurs the "data" field will contain the error object.

If no response is received, the "data" field contains a generic error message and the status code is -1.

Implementation

Future<JSON?> post(
    {required String host,
    String? path,
    Map<String, String>? queryParameters,
    Map<String, String>? headers,
    JSON? body,
    bool isHttps = true});