webread
Read content from RESTful web service
Syntax
Description
appends query parameters to data = webread(url,QueryName1,QueryValue1,...,QueryNameN,QueryValueN)url, as specified by one or more
pairs of parameter names and values. 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 specify this argument in addition to
any of the input argument combinations in 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,
webreadreturns all output arguments.If you specify a handle to a function that returns no output argument (such as Image Processing Toolbox™ function
@implayfor video files),webreadreturns 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.
Examples
Input Arguments
Output Arguments
More About
Tips
For functionality not supported by the RESTful web services functions, see Call Web Services from MATLAB Using HTTP.
The web services APIs only support HTTP 1.1.
webreadsupports HTTP GET and POST methods. Many web services provide both GET and POST methods to request data. To send an HTTP POST request, specify theRequestMethodproperty ofoptionsas"post". However,webreadputs query options into theurl, not in the body of the request message. To put a query into the body, usewebwrite.For HTTP POST requests, the
webreadfunction supports only theapplication/x-www-form-urlencodedmedia type. To send a POST request with content of any other internet media type, usewebwrite.This function does not examine the web 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 defaultwebreadencoding, then specify the intendedCharacterEncodingoption inweboptions.For information on how to specify proxy server settings, see Proxy Server Authentication.
Extended Capabilities
Version History
Introduced in R2014bSee Also
Functions
websave|weboptions|webwrite|datetime|jsondecode|audioread|imread|readtable|xmlread

