REST API Usage Examples
- Last UpdatedFeb 24, 2021
- 2 minute read
Following is an example of a REST API for ArchestrA scripting. This example updates a single parameter.
NOTE: The GetMany() call used here only returns "Frequently Used" parameters. The second example shows how to get all parameters.

The following example is much more efficient when setting several (or all) parameters in a Recipe.
This example also shows some detailed exception handling. It is in textual format so that you can copy and paste:
dim restAPI as ArchestrA.Web.RestAPI;
dim equipParamsResource as ArchestrA.Web.Resource;
dim equipParams[1] as ArchestrA.Web.Resource;
dim equipParam as ArchestrA.Web.Resource;
try
' Initialize the client API
restAPI = new ArchestrA.Web.RestAPI(Me.RMPServerName, "https://" + Me.RMPServerName + "/recipemanagement/");
'In order to be able to resubmit all recipe parameters, get the set as a resource object.
equipParamsResource = restAPI.GetOne("api/RecipeParameterMaps/?EquipmentName=" + Me.EquipmentName + "&showAllRuntimeParametersFilter=true");
'Now convert the resource to an array so we can update each element
equipParams[] = equipParamsResource.ToArray();
' write a value to each parameter
for each equipParam in equipParams []
' this assumes we can write the value 50 to all parameters
equipParam.SetProperty("FormulaTargetValue", "50");
next;
' by sending the original resource object to bulkchange, we update all parameters at once
restAPI.Put("api/RecipeParameterMaps/bulkchange", equipParamsResource);
LogMessage("Done updating parameters for Recipe on Equipment " + Me.EquipmentName);
catch
dim rex as ArchestrA.Web.RestAPIException;
rex = error;
dim commandError as ArchestrA.Web.Resource;
if rex <> null and rex.Resource <> null and rex.Resource.ResourceType == "ViewCommandResult" then
' Validation type error - value out of limit, etc.
commandError = rex.Resource.GetPropertyAsResource("CommandError");
LogMessage("ErrorCode: " + commandError.GetProperty("ErrorCode") +
" ErrorMessage: " + commandError.GetProperty("ErrorMessage") +
" Exception HttpStatus: " + rex.HttpStatus);
elseif rex <> null then
' Lower level Http type error
LogMessage("ErrorMessage: " + rex.Message +
" Exception HttpStatus: " + rex.HttpStatus);
else
' Unknown exception
LogMessage("Error Message: " + error.Message );
endif;
endtry;