Read content from RESTful web service
appends query parameters to data
= webread(url
,QueryName1,QueryValue1,...,QueryNameN,QueryValueN
)url
, as specified by one or more
pairs of name-value arguments. To put a query into the body of the message, use
webwrite
. The web service defines the query
parameters.
adds other HTTP request options, specified by the data
= webread(___,options
)weboptions
object options
. You can use this syntax with any of the input
arguments of the previous syntaxes.
To return data as a specific output type, specify the
ContentType
property of
options
.
To read content with a function, specify the ContentReader
property of options
as a handle to the function.
webread
downloads data from a web service and reads the
data with the specified function:
If you specify a handle to a function that returns multiple output
arguments, webread
returns all output
arguments.
If you specify a handle to a function that returns no output
argument (such as Image Processing Toolbox™ function @implay
for video files),
webread
returns no output argument.
[
reads an image from the web
service specified by data
,colormap
,alpha
]
= webread(___)url
and returns the image
in data
. You can use the previous syntaxes to return
the image only. Use this syntax to return the colormap and alpha channels
associated with the image.
webread
returns an image when the HTTP response has a
Content-Type
header field that specifies an image media
type and if imread
supports the image format. For supported
image formats, see Supported File Formats for Import and Export.
[
reads audio data from the web
service specified by data
,Fs
]
= webread(___)url
and returns the audio
data in data
. You can use the previous syntaxes
to return the audio data only. Use this syntax to return the sample
rate of the audio data in hertz.
webread
returns audio data when the HTTP response has a
Content-Type
header field that specifies an audio media
type and if audioread
supports the audio format. For
supported audio formats, see Supported File Formats for Import and Export.
For functionality not supported by the RESTful web services functions, see the HTTP Interface.
webread
supports HTTP GET and POST methods. Many web
services provide both GET and POST methods to request data. To send an HTTP POST
request, specify the RequestMethod
property of
options
as 'post'
. However,
webread
puts query options into the
url
, not in the body of the request message. To put a
query into the body, use webwrite
.
For HTTP POST requests, the webread
function
supports only the application/x-www-form-urlencoded
media
type. To send a POST request with content of any other internet media
type, use webwrite
.
This function does not examine the document contents to determine how to
process it. For example, HTML and XML documents often contain a
<meta>
tag that specifies the document character
encoding. If the encoding is different from the default
webread
encoding, then specify the correct
CharacterEncoding
option in
weboptions
.
audioread
| datetime
| imread
| jsondecode
| readtable
| weboptions
| websave
| webwrite
| xmlread