नोट
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप साइन इन करने या निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
Applies to:
Databricks SQL
Databricks Runtime 16.2 and above
Makes an HTTP request using a defined HTTP connection.
This function requires named parameter invocation.
Syntax
http_request( { CONN => connectionName |
METHOD => httpMethod |
PATH => path |
HEADERS => headerMap |
PARAMS => paramMap |
JSON => jsonStr } [, ..] )
Arguments
An error is raised if a parameter is specified more than once.
-
A
STRINGconstant referencing an existing HTTP connection identifier. This argument is required httpMethodA
STRINGconstant expression representing the HTTP method to use. The following methods are supported: 'GET', 'POST', 'PUT', 'DELETE', 'PATCH'. This argument is required.pathA
STRINGconstant expression which gets appended to thebase_pathof the connection URL. The path must not contain directory traversal (../..). This argument is required.headerMapAn optional
MAP<STRING, STRING>containing request headers. The default isNULL.paramMapAn optional
MAP<STRING, STRING>with request query params in JSON format. The default isNULL.jsonStrAn optional JSON string expression with the request body.
Returns
A STRUCT<status_code INT, text STRING> where
status_codeis the HTTP status code of the response from the external service. For example: 200 or 403.textis the response returned by the external service. Typically, this is a JSON string.
Examples
-- Set up a connect to Slack.
> CREATE CONNECTION slack_conn
TYPE HTTP
OPTIONS (
host 'https://slack.com',
port '443',
base_path '/api/',
bearer_token 'xoxb-xxxxx'
);
-- Request to the external service
> SELECT http_request(
conn => 'slack_conn',
method => 'POST',
path => '/chat.postMessage',
json => to_json(named_struct(
'channel', channel,
'text', text
))
headers => map(
'Accept', "application/vnd.github+json",
)
);