Main Content

matlab.net.http.StatusCode.fromValue

Class: matlab.net.http.StatusCode
Package: matlab.net.http

Create StatusCode object from string or number

Description

example

code = matlab.net.http.StatusCode.fromValue(value) converts value to a StatusCode enumeration. Use this method to create a StatusCode object for comparisons.

Input Arguments

expand all

Number to convert, specified as a positive integer or a positive integer string.

Attributes

Statictrue

Examples

expand all

Compare a response status code with a value from an external source that lists status codes as numbers or strings.

Assume that you have the status code from a response message.

class(resp.StatusCode)
ans = matlab.net.http.StatusCode

Compare the code with value 401 from the table using the fromValue method.

theValue = '401';
if resp.StatusCode == matlab.net.http.StatusCode.fromValue(theValue)
    % do something
end

See Also

Introduced in R2016b