Why do I get "AxiosError" when submitting certain array datatypes to the MATLAB Production Server?

I can successfully deploy JSON requests to the MATLAB Production Server (MPS) in MATLAB R2022a when including data for variables like integer arrays. However, when including string arrays in the JSON input, I am unable to send the request to the MPS and get the following error:

AxiosError: Request failed with status code 400
I am following the documentation below for formatting string arrays in the JSON notation, so I can't figure out what the issue is:
https://www.mathworks.com/help/releases/R2022a/mps/restfuljson/json-representation-of-matlab-data-types.html
What is the reason for this issue?

 Accepted Answer

Submitting code to the MPS can fail for certain datatypes if the JSON input data is structured incorrectly. Please ensure that any data items read by the MPS are encapsulated inside of the "mwdata" field. For example, the following JSON input can trigger this issue, since data for "start" and "end" are outside of the "mwdata" field:
{
"nargout": 1,
"rhs": [
{
"start": 0,
"end": 0,
"fields": {
"mwdata": {
"var1": [
"x",
"y"
],
...
In this case, you can use the functions below to correctly structure a new request to submit to the MPS:
  • "mps.json.encoderequest" (for converting MATLAB data in a server request to JSON text):
  • "mps.json.encode" (for converting MATLAB data outside a server request to JSON text):
  • "mps.json.decoderesponse" (for converting JSON text from a server response to MATLAB data):
  • "mps.json.decode" (for converting a character vector or string in MATLAB Production Server JSON schema to MATLAB data):

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!