Skip to main content

post

post

Performs an HTTP POST request with a request body. When the merged Content-Type is application/json and data is an object, it's serialized to a JSON string automatically. Otherwise data is sent as-is.

Parameters

NameTypeDescription
urlStringThe URL to request
headersMap?Request headers. Optional (null). Merged into the default headers (Content-Type: application/json, Accept: application/json) before sending
datadynamicThe request body. Serialized to a JSON string automatically when Content-Type is application/json and the value is an object (Map)
jsCallbackJSFunction?The callback that receives the response

Callback

Invoked as jsCallback(statusCode, headers, body).

ArgumentTypeDescription
statusCodenumberThe response status code
headersMapThe response headers
bodyStringThe response body

Returns: void

Example

$http.post("https://api.example.com/user", {}, { name: "Lucy" }, function (status, headers, body) {
$log.d(status, body);
});