Web

Last Updated On 2021-07-16

Version 7MinSDK 7Tutorial Video

Non-visible component that provides functions for HTTP GET, POST, PUT, and DELETE requests.


Properties

You can set the below properties in the UI part of the builder.

  • AllowCookies - it's a boolean value which is set to false by default.
  • ResponseFileName - it's a string value which is set to blank by default.
  • SaveResponse - it's a boolean value which is set to false by default.
  • Timeout - it's a non negative integer value which is set to 0 by default.
  • Url - it's a string value which is set to blank by default.

Block Properties

You can set the below blocks properties in the blocks section of the builder.

AllowCookies

Whether the cookies from a response should be saved and used in subsequent requests. Cookies are only supported on Android version 2.3 or greater.


RequestHeaders

The request headers, as a list of two-element sublists. The first element of each sublist represents the request header field name. The second element of each sublist represents the request header field values, either a single value or a list containing multiple values.


ResponseFileName

The name of the file where the response should be saved. If SaveResponse is true and ResponseFileName is empty, then a new file name will be generated.


SaveResponse

Whether the response should be saved in a file.


Timeout

The number of milliseconds that a web request will wait for a response before giving up. If set to 0, then there is no time limit on how long the request will wait.


Url

The URL for the web request.



Methods

You can set the below method blocks in the blocks section of the builder.

BuildRequestData

Converts a list of two-element sublists, representing name and value pairs, to a string formatted as application/x-www-form-urlencoded media type, suitable to pass to PostText.

ClearCookies

Clears all cookies for this Web component.

Delete

Performs an HTTP DELETE request using the Url property and retrieves the response. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.

Get

Performs an HTTP GET request using the Url property and retrieves the response. If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file. If the SaveResponse property is false, the GotText event will be triggered.

HtmlTextDecode

Decodes the given HTML text value. HTML character entities such as &amp;, &lt;, &gt;, &apos;, and &quot; are changed to &, <, >, ', and ". Entities such as &#xhhhh, and &#nnnn are changed to the appropriate characters.

JsonObjectEncode

Returns the value of a built-in type (i.e., boolean, number, text, list, dictionary) in its JavaScript Object Notation representation. If the value cannot be represented as JSON, the Screen's ErrorOccurred event will be run, if any, and the Web component will return the empty string.

JsonTextDecode

Decodes the given JSON encoded value to produce a corresponding AppInventor value. A JSON list `[x, y, z]` decodes to a list `(x y z)`, A JSON object with key A and value B, (denoted as `

JsonTextDecodeWithDictionaries

Decodes the given JSON encoded value to produce a corresponding App Inventor value. A JSON list [x, y, z] decodes to a list (x y z). A JSON Object with name A and value B, denoted as \

PostFile

Performs an HTTP POST request using the Url property and data from the specified file.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.

PostText

Performs an HTTP POST request using the Url property and the specified text.
The characters of the text are encoded using UTF-8 encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.

PostTextWithEncoding

Performs an HTTP POST request using the Url property and the specified text.
The characters of the text are encoded using the given encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.

PutFile

Performs an HTTP PUT request using the Url property and data from the specified file.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.

PutText

Performs an HTTP PUT request using the Url property and the specified text.
The characters of the text are encoded using UTF-8 encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The responseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.

PutTextWithEncoding

Performs an HTTP PUT request using the Url property and the specified text.
The characters of the text are encoded using the given encoding.
If the SaveResponse property is true, the response will be saved in a file and the GotFile event will be triggered. The ResponseFileName property can be used to specify the name of the file.
If the SaveResponse property is false, the GotText event will be triggered.

UriDecode

Decodes the encoded text value so that the values aren't URL encoded anymore.

UriEncode

Encodes the given text value so that it can be used in a URL.

XMLTextDecode

Decodes the given XML string to produce a dictionary structure. See the App Inventor documentation on "Other topics, notes, and details" for information.

XMLTextDecodeAsDictionary

Decodes the given XML into a set of nested dictionaries that capture the structure and data contained in the XML. See the help for more details.


Events

You can set the below event blocks in the blocks section of the builder.

GotFile

Event indicating that a request has finished.

GotText

Event indicating that a request has finished.

TimedOut

Event indicating that a request has timed out.