POST Synchronous Request
Make synchronous request to MATLAB REST function service and wait for response
Since R2024a
Description
Use a POST method to make a synchronous request to a MATLAB® REST function service.
Uses JSON as the data serialization format.
Request
HTTP Method
POST
URI
https://<hostname>:<port>/matlab/feval/v1/<matlabFunctionName>
Query Parameters
None.
Content-Type
application/json
Body
Name | Description | Value-Type |
---|---|---|
nargout | Number of outputs that the client application is requesting from the
MATLAB function. Note that MATLAB functions, depending on their intended purpose, can be coded to
return multiple outputs. A subset of these potential outputs can be specified
using | number |
rhs | Input arguments to the MATLAB function, specified as an array of comma-separated values. | [arg1,arg2,arg3,...] |
outputFormat | Specify whether the MATLAB output in the response should be returned using large or small
JSON notation, and whether For more information on the JSON representation of MATLAB data types, see JSON Representation of MATLAB Data Types (MATLAB Production Server). | { "mode" : "small | large", "nanInfFormat" : "string | object"
} |
Response
Success
Name | Description | Value-Type |
---|---|---|
lhs | A JSON |
|
Error
Standard HTTP status codes.
Sample Call
HTTP
This example shows how to create a POST request to call res =
mySqrt(25)
using this MATLAB function.
function result = mySqrt(x) result = sqrt(x); end
Request:
POST /matlab/feval/v1/TestService/mySqrt HTTP/1.1 Host: localhost:9920 mwRESTPersonalAccessToken: VAAKeo/2MaCzb72rMv1TX0df/HbjSSL47kWy5B694BE= Content-Type: application/json Content-Length: 80 {"rhs":[25.0], "nargout":1, "outputFormat":{"mode":"small", "nanType":"string"}} |
For more information about this example, see Call User-Defined Function with MATLAB REST Function Services.
Version History
Introduced in R2024a