I got errors below trying to converting a type to string, like below:
<set-variable name="a" value="@(context.Variables["a"].ToString())" />
Error in element 'set-variable' on line 16, column 10: Usage of member 'ToString' of type 'System.Object' is not supported within expressions
<set-variable name="a" value="@(context.Variables["a"])" />
Error in element 'set-variable' on line 16, column 10: Expression return type 'System.Object' is not allowed
https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions