HttpRequest

Makes an HTTP Request to a URI/URL

  • Stored Procedure
  • SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017

Syntax:

EXEC SQLHTTP.net.HttpRequest @HttpSessionID, @URL, [@Method], [@Body], [@IsBodyPathToFile], [@Response OUTPUT], [@StatusCode OUTPUT], [@StatusDescription OUTPUT], [@ContentType], [@Accept], [@AcceptEncoding], [@AcceptLanguage], [@AllowAutoRedirect], [@Connection], [@KeepAlive], [@AllowWriteStreamBuffering], [@Timeout], [@ReadWriteTimeout], [@Referer], [@Expect], [@MaximumAutomaticRedirections], [@SendChunked], [@TransferEncoding], [@MediaType], [@ProxyHost], [@ProxyPort], [@IgnoreCertErrors], [@HttpQueueTimeout], [@HttpQueueID OUTPUT], [@DebugMode]

Arguments:

Name Type Description
@HttpSessionID uniqueidentifier Required. This value is obtained via the HttpSession stored procedure/td>
@URL nvarchar(4000) Required. Web address starting with http:// or https://
@Method varchar(10) Optional. Protocol method to use in this request.
Default: GET
@Body nvarchar(MAX) Optional. Data to send with a POST Method
@IsBodyPathToFile bit Optional. Boolean value indicating whether the @Body parameter contains a path to a file. If true, the @Body parameter will be replaced with the content of the file. This feature is useful when submitting a file to a website. See the stored procedure on this page for an example. Default: 0 (false)
@Response nvarchar(MAX) Optional. Output Parameter. Data received from the web request. Binary data is returned as a Base64 string
@StatusCode int Optional. Output Parameter. Numeric status of the HTTP response
@StatusDescription nvarchar(MAX) Optional. Output Parameter. Status Description returned with the response
@ContentType nvarchar(4000) Optional. Value of the Content-type HTTP header
@Accept nvarchar(4000) Optional. Value of the Accept HTTP header
@AcceptEncoding nvarchar(4000) Optional. Value of the Accept-Encoding HTTP header
@AcceptLanguage nvarchar(4000) Optional. Value of the Accept-Language HTTP header
@AllowAutoRedirect bit Optional. Indicates whether the request should follow redirection responses.
Default: 0 (false)
@Connection nvarchar(4000) Optional. Value of the Connection HTTP header
@KeepAlive bit Optional. Indicates whether to make a persistent connection to the Internet resource.
Default: 1 (true)

 

@AllowWriteStreamBuffering bit Optional. Indicates whether to buffer the data sent.
Default: 1 (true)
@Timeout int Optional. Time in milliseconds for the server to respond to a request.
Default: 100,000
@ReadWriteTimeout int Optional. Time in milliseconds to wait for the server to transmit all the data. Default: 300,000
@Referer nvarchar(4000) Optional. Value of the Referer HTTP header
@Expect nvarchar(4000) Optional. Value of the Expect HTTP header
@MaximumAutomaticRedirections int Optional. The maximum number of redirects that the request follows.
Default: 50
@SendChunked bit Optional. Indicates whether to send data in segments to the Internet resource. Default: 0 (false)
@TransferEncoding nvarchar(4000) Optional. Value of the Transfer-encoding HTTP header
@MediaType nvarchar(4000) Optional. Media Type of the request
@ProxyHost nvarchar(4000) Optional. Web address of an HTTP Proxy
@ProxyPort int Optional. Port value to use with @ProxyHost.
Default: 80
@IgnoreCertErrors bit Optional. Indicates whether to ignore certificate errors.
Default: 0 (false)
@HttpQueueTimeout int Optional. Time in milliseconds for the SQLHTTP Agent to complete processing a request. Setting this value directs SQLHTTP to use the SQLHTTP Agent to process this HTTP request.

Values greater than 0 instruct the stored procedure to wait until the SQLHTTP Agent completes processing the HTTP request or the timeout is reached. A Value of 0 exits the stored procedure allowing the SQLHTTP Agent to proceed asynchronously.

Default: NULL (processing will be completely performed in the SQL Server process)

@HttpQueueID int Optional. Output Parameter. The unique ID of the SQLHTTP Agent queue processing this HTTP request, where applicable

Sample Usage:

See Also: