http_request_post plugin

Learn how to use the http_request_post plugin to send an HTTP request and convert the response into a table.

services: data-explorer

http_request_post plugin

The http_request_post plugin sends an HTTP POST request and converts the response into a table.

Prerequisites

Syntax

evaluate http_request_post ( Uri [, RequestHeaders [, Options [, Content]]] )

Parameters

NameTypeRequiredDescription
Uristring✔️The destination URI for the HTTPS request.
RequestHeadersdynamicA property bag containing HTTP headers to send with the request.
OptionsdynamicA property bag containing additional properties of the request.
ContentstringThe body content to send with the request. The content is encoded in UTF-8 and the media type for the Content-Type attribute is application/json.

Authentication and authorization

To authenticate, use the HTTP standard Authorization header or any custom header supported by the web service.

Returns

The plugin returns a table that has a single record with the following dynamic columns:

  • ResponseHeaders: A property bag with the response header.
  • ResponseBody: The response body parsed as a value of type dynamic.

If the HTTP response indicates (via the Content-Type response header) that the media type is application/json, the response body is automatically parsed as-if it’s a JSON object. Otherwise, it’s returned as-is.

Headers

The RequestHeaders argument can be used to add custom headers to the outgoing HTTP request. In addition to the standard HTTP request headers and the user-provided custom headers, the plugin also adds the following custom headers:

NameDescription
x-ms-client-request-idA correlation ID that identifies the request. Multiple invocations of the plugin in the same query will all have the same ID.
x-ms-readonlyA flag indicating that the processor of this request shouldn’t make any persistent changes.

Example

The following example is for a hypothetical HTTPS web service that accepts additional request headers and must be authenticated to using Microsoft Entra ID:

let uri='https://example.com/node/js/on/eniac';
let headers=dynamic({'x-ms-correlation-vector':'abc.0.1.0', 'authorization':'bearer ...Azure-AD-bearer-token-for-target-endpoint...'});
evaluate http_request_post(uri, headers)