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[obj,]

executes the cloud object obj.

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:
  • AuthenticationNoneauthentication information to send
    CharacterEncodingAutomaticcharacter encoding for strings sent
    CookieFunctionAutomaticfunction to apply to each cookie received
    FollowRedirectsTruewhether to follow HTTP redirects
    InteractiveTruewhether to allow interactive authentication dialogs
    TimeConstraintInfinitytime to wait for a response
    VerifySecurityCertificatesTruewhether 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:

In[1]:=
Click for copyable input
Out[1]//Short=

Execute PlaceHold.it API and import the result as an image:

In[1]:=
Click for copyable input
Out[1]=

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

In[1]:=
Click for copyable input
Out[1]=

Draw four cards from this deck:

In[2]:=
Click for copyable input
Out[2]=

Show the cards:

In[3]:=
Click for copyable input
Out[3]=

Execute an APIFunction:

In[1]:=
Click for copyable input
Out[1]=

URL objects can be used:

In[1]:=
Click for copyable input
Out[1]=

Options  (4)

Possible Issues  (1)

See Also

URLRead  Import  ServiceExecute  SystemOpen  URLBuild  CloudEvaluate  CloudConnect  APIFunction  URLDispatcher  URLResponseTime  PingTime

Introduced in 2014
(10.0)
| Updated in 2016
(11.0)