Unauthorized error when trying to use Maintenance Mode

I have a Citrix environment with a machine template and 4 host machines connected. I need to set Maintenance Mode 1 host machine at a time.
I am using OAuth2 to set Maintenance Mode. I have a confidential, external application connection set with OR.Administration for the application scope. With an Http request activity, I can authenticate and receive an access token using the appid and secret from the external application setup. however, I get “Unauthorized” 403 error code when trying to set the HostMachineName to Maintenance Mode.
This is the set up of the HTTP request:

This is the body (this may be the issue??):

I have selected OAuth2 and put the bearer token in the OAuth2Token field.

Error Message: “{"message":"You are not authorized!","errorCode":0,"result":null,"targetUrl":null,"success":false,"error":{"code":0,"message":"You are not authorized!","details":"You are not allowed to perform this operation.","validationErrors":null},"unAuthorizedRequest":true,"__abp":true}”

@gregg.rubright

Where did you pass the bearer token?

I dont see that at all?

cheers

I passed it originally in the OAuth2Token field, but it kept disappearing so I moved it to a header but got the same error:

FYI, this is the setup of my External Application connection(App Scopes are OR.Administration and OR.Robots (which I probably don’t need)):

I got this done by using the HTTP Request activity, with the following endpoint:
odata/Sessions/UiPath.Server.Configuration.OData.SetMaintenanceMode

And the following payload:
{ "sessionId":“+row[“ServerID”].ToString()+”, "maintenanceMode":"Enabled", "stopJobsStrategy":"SoftStop" }

I could not find ANY documentation on this endpoint anywhere, but it is in the Swagger.

The endpoint with documentation “api/maintenance/start”, I could not get to work at all. Kept giving me an “Unauthorized” or “Forbidden” error. Therefore, I wouldn’t really consider this a solution, but rather, a work around.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.