Approving a request using API

Approving a request using API

Hello, I'm trying to use the API to approve a request but can't seem to get it to work. I have two use cases in mind that I'm developing, both of which are using the same request template with two approval levels. To explain context I'll briefly explain the template. The template is used to request activating/deactivating a permission level for an external system so that the requests tasks, connected to the external system, can be tracked and performed in a uniform manner every time.

- 1: The form contains both a field for activation-date and deactivation-date (not mandatory). I wrote a script connected to a custom trigger that creates a linked request of the same template when you request to activate a permission level and the field for deactivation-date is filled. This linked request is created to track and perform the deactivation of said permission and the correct date. However, since this happens automatically and only after a request has been approved I wish to include to also automatically approve both approval levels in the script.

- 2: Depending on who in the hierachy creates the request I also wish to implement so that all approvals below the requesters "level" is automatically approved. Meaning if someone who's included in the group set to perform level 2 of the approval levels creates this request - level 1 should be automatically approved without any manual intervention.

Now, with all of that explained I have attempted to use the REST API Documentation to do this, but to no avail. Although I must say I'm somewhat confused by the REST API Documentation stating the following to approve a request: /api/v3/requests/{request_id}/approval_levels/{level_number}/approvals/{approval_id}/_approve
But in this User Guide it's shown as: /api/v3/requests/{request_id}/approval_levels/{approval_level_id}/approvals/{approval_id}/_approve

I'm assuming approval_level_id is correct, because when entering the id found from /api/v3/requests/{request_id}/approval_levels results in a response saying I'm not authorized, while using the level_number (a.k.a 1 or 2 in my case?) results in Invalid URL.

How do I get around this? Both when attempting to make this call from python (with technician key/authtoken) and directly on the APIdoc I get the same result. Do I have to change something regarding the user groups used in the approval levels? I'd prefer to not clutter them.

What should I do?

                New to ADSelfService Plus?