MiddlewareAccess_Post (Post)
- Last UpdatedNov 06, 2025
- 3 minute read
| Post | MiddlewareAccess_Post |
Resource Path:/api/MiddlewareAccess
Add data by submitting an XML request that specifies a stored procedure or by specifying a stored procedure directly.
- When submitting an XML request, the XML string is supplied in the request body.
- When specifying a stored procedure directly, you must include the sessionId parameter in the URL and supply the JSON string in the request body. If the URL does not include the sessionId parameter, then the method assumes that an XML string is being passed in the request body.
| Name | Description | Data Type |
|---|---|---|
| sessionId | Required when submitting a stored procedure directly request. The session ID of the current user. | string |
The request body is of type string.
XML Request
For an XML request, the request body holds the XML string contents. See Specifying MES Stored Procedures in a MiddlewareAccess XML Endpoint for a description of the XML string contents.
Specifying a Stored Procedure Directly
When specifying a stored procedure directly, the request body holds the JSON string contents. The JSON can include one or more commands.
The JSON contains at least one object and command pair that are combined to create the middleware command obj.cmd. This middleware command is used to identify the stored procedure either by looking it up in the middleware mapping file or, if the command is not in the mapping file, by creating the name as sp_U_obj_cmd.
If one or more parameters are required by the stored procedure associated with the command, the string array must include the parameters and their values. The parameter portion of the string must be an array of name/value pairs:
- The name should match the name of a parameter in the stored procedure being called without the @ character.
- The value is the value being passed in for the parameter.
Each parameter name/value pair should be supplied only once.
The content supplied in the JSON string can represent a single command or a batch of commands.
For a single command, the JSON string has the following structure:
{ obj:table, cmd:command, parms:[{param_name:param_value}, {param_name:param_value}...] }
For a batch of commands, the JSON string has the following structure:
{ cmds:[ { obj:table, cmd:command, parms:[{param_name:param_value}, {param_name:param_value}...] }, { obj:table, cmd:command, parms:[{param_name:param_value}, {param_name:param_value}...] }, . . . ] }
The response body is of type string.
The endpoint returns a JSON array that represents the object that was added.
Examples of Submitting an XML Request
Here's an example of calling a Post for a single command and the response.
Post for a single command (URL and request body):
fullyqualifiedhostname/mesmw/api/MiddlewareAccess
<request><object>util_state</object><cmd>add</cmd><msgtype>exec</msgtype><util_state><state_desc>Planned Downtime</state_desc><color>255</color></util_state></request>Response body:
{"result":0,"state_cd":"363","identity":363,"last_edit_at":"2020-08-27T11:53:27Z"}
Here's an example of calling a Post for a batch of commands and the response.
Post for a batch of commands (URL and request body):
fullyqualifiedhostname/mesmw/api/MiddlewareAccess
<requests><object>custom</object><cmd>ExecuteBatchXMLCmds</cmd><msgtype>execbatch</msgtype><request><object>util_state</object><cmd>add</cmd><msgtype>exec</msgtype><util_state><state_desc>Unplanned Downtime</state_desc><color>255</color></util_state></request><request><object>util_state</object><cmd>add</cmd><msgtype>exec</msgtype><util_state><state_desc>Running Slow</state_desc><color>255</color></util_state></request></requests>Response body:
{"result":0,"add":[{"result":0,"state_cd":"366","identity":366,"last_edit_at":"2020-08-27T12:01:06Z"},{"result":0,"state_cd":"367","identity":367,"last_edit_at":"2020-08-27T12:01:06Z"}]}
Examples of Submitting a Stored Procedure Directly
Here's an example of calling a Post for a single command and the response.
Post for a single command (URL and request body):
fullyqualifiedhostname/mesmw/api/MiddlewareAccess?sessionId=23
{"obj":"util_state","cmd":"add","parms": [{"state_desc":"Planned Downtime","color":"255"}]}Response body:
{"result":0,"state_cd":"362","identity":362,"last_edit_at":"2020-08-27T11:33:54Z"}
Here's an example of calling a Post for a batch of commands and the response.
Post for a batch of commands (URL and request body):
fullyqualifiedhostname/mesmw/api/MiddlewareAccess?sessionId=23
{"cmds":[{"obj":"util_state","cmd": "add","parms":[{"state_desc":"Unplanned Downtime","color": "255"}]},{"obj":"util_state","cmd": "add","parms":[{"state_desc":"Running Slow","color":"255"}]}]}Response body:
{"result":0,"add":[{"result":0,"state_cd":"364","identity":364,"last_edit_at":"2020-08-27T11:57:06Z"},{"result":0,"state_cd":"365","identity":365,"last_edit_at":"2020-08-27T11:57:06Z"}]}The session ID for the transaction is determined as follows:
- For an XML request, the method will search the supplied parameter list looking for a session_id parameter. If a session_id parameter is found, the value will be passed to the XMLExecBuilder constructor as the sessionID value. For the call to succeed, the session_id parameter value must be an integer and must be in the Sessn table.
- When supplying the stored procedure directly, the method uses session ID supplied in the URL.