URLExecute

URLExecute[url]

executes the specified URL, importing whatever result is generated.

URLExecute[url,{"param1"val1,"param2"val2,}]

executes the specified URL, adding elements with names parami and values vali.

URLExecute[url,params,format]

imports the result using the specified format.

URLExecute[CloudObject[],]

executes a cloud object with current authentication settings.

URLExecute[HTTPRequest[],]

executes the specified HTTP request.

Details and Options

  • In URLExecute[url], url can be a string, a URL object, or a cloud object.
  • URLExecute[assoc] is equivalent to URLExecute[HTTPRequest[assoc]].
  • For simple forms of the vali such as numbers and short strings, URLExecute performs a GET request, with the parami specifying parameters in the query string. In other cases, it performs a POST request.
  • The vali can be strings or numbers, or the following special forms:
  • None,Null,Missing""
    True"true"
    False"false"
    {e1,e2,}e1, e2,
    imagean image in default format
    ExportForm[expr,form]any expression, exported in the specified form
    File["file"]the contents of a file
  • URLExecute supports the following options:
  • AuthenticationAutomaticauthentication information to send
    CharacterEncodingAutomaticcharacter encoding for strings sent
    CookieFunction Automaticfunction to apply to each cookie received
    FollowRedirects Truewhether to follow HTTP redirects
    InteractiveTruewhether to allow interactive authentication dialogs
    TimeConstraint Infinitytime to wait for a response
    VerifySecurityCertificates Truewhether to verify SSL security certificates
  • The setting CharacterEncoding->"enc" specifies that all strings that appear in the request should be encoded using the encoding enc before being sent to the server.
  • The setting CharacterEncoding->None specifies that no change should be made to strings before sending them to the server.
  • With CharacterEncoding->Automatic, the encoding is taken from the "ContentType" element if this is specified; otherwise, the encoding is "UTF8".
  • TimeConstraint->t allows a maximum of t seconds for connection to the URL and reading from it.
  • TimeConstraint-><|"Connecting"->tc,"Reading"->tr|> specifies separate timeouts for connecting to the URL and reading from it.
  • URLExecute[url] and URLExecute[url,params] import the result from the URL, automatically determining the format to use. JSON is by default imported in "JSON" format.
  • In URLExecute[url,params,format], format can be any format supported by Import.

Examples

open allclose all

Basic Examples  (5)

Execute a URL and import the result from a JSON API:

Execute picsum API and import the result as an image:

Create a deck of cards on http://deckofcardsapi.com:

Draw four cards from this deck:

Show the cards:

Execute an APIFunction:

URL objects can be used:

Options  (4)

CookieFunction  (1)

Apply a function to each cookie received when an HTTP response is received:

FollowRedirects  (1)

Specify whether to follow HTTP redirects when retrieving a URL:

TimeConstraint  (1)

Specify the maximum allowed time in seconds to finish downloading data from the server:

VerifySecurityCertificates  (1)

Verify that the SSL certificate used by the server is valid:

Wolfram Research (2014), URLExecute, Wolfram Language function, https://reference.wolfram.com/language/ref/URLExecute.html (updated 2016).

Text

Wolfram Research (2014), URLExecute, Wolfram Language function, https://reference.wolfram.com/language/ref/URLExecute.html (updated 2016).

CMS

Wolfram Language. 2014. "URLExecute." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/URLExecute.html.

APA

Wolfram Language. (2014). URLExecute. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/URLExecute.html

BibTeX

@misc{reference.wolfram_2023_urlexecute, author="Wolfram Research", title="{URLExecute}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/URLExecute.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_urlexecute, organization={Wolfram Research}, title={URLExecute}, year={2016}, url={https://reference.wolfram.com/language/ref/URLExecute.html}, note=[Accessed: 19-March-2024 ]}