Building an HTTP request for a costum request for others workflow

Hello everyone I’m building a costum request for others trough a workflow. In this costum request for others the user is able to choose to request a fixed number of role or access profile, for example he can request 3 roles or 2 roles. After that he must select for each role a sunset date. After that I have to built an access request sending it trough API. I’m having troubles on this last point that I’m trying to realize trough a loop:


The variable i’m looping on is the role array, because it could be 1 or more:

The HTTP request inside the loop is the Submit request (tenant/v3/access-requests). In the request body I’m currently putting this JSON:

{
    "requestType": "GRANT_ACCESS",
    "requestedBy": [
        "{{$.trigger.launchedBy.id}}"
    ],
    "requestedFor": [
        "{{$.interactiveForm6.formData.requestForOthers}}"
    ],
    "requestedItems": [
        {
            "comment": " ",
            "id": "{{$.loop.loopInput}}",
            "removeDate": "{{$.interactiveForm4.formData.getIndex($.interactiveForm1.formData.selectRole.getIndex($.loop.loopInput))}}",
            "type": "ROLE"
        }
    ]
}
  • In which {{$.trigger.launchedBy.id}} is who is launching the interactive process trough the launchpad.
  • "{{$.interactiveForm6.formData.requestForOthers}}" is the recipient of the request.
  • {{$.loop.loopInput}} contains the actual id of the access item to request.
  • {{$.interactiveForm4.formData.getIndex($.interactiveForm1.formData.selectRole.getIndex($.loop.loopInput))}} is the sunset date for that specific access item that i’m considering in the loop.

When launching the workflow I retrieve this problem inside the loop:

{
  "loopOutput": {
    "failureItems": [
      {
        "errorMessage": "task failed: activity error (type: sp:external:http:v2, scheduledEventID: 5, startedEventID: 6, identity: 1@sp-workflow-worker-stg-eu-central-1-5cffff5b96-58hml@sp-workflow-engine): request failed (type: HTTP Response Returned a Client Error, retryable: false): request failed: 400 - 400 Bad Request - {\"detailCode\":\"400.0 Bad request syntax\",\"trackingId\":\"e7bf4113b7d04238ace967330d2e66c8\",\"messages\":[{\"locale\":\"en-US\",\"localeOrigin\":\"DEFAULT\",\"text\":\"The request could not be parsed.\"},{\"locale\":\"und\",\"localeOrigin\":\"REQUEST\",\"text\":\"The request could not be parsed.\"}],\"causes\":[]}",
        "payload": null
      }
    ],
    "successfulItems": []
  }
}

I think I’m having problem in the last point . The problem is that I can’t use two innested loop , so I’m traying to craffing for each access item an access request and each access item must have a sunset date, so I’m trying to extract the sunset date from the sunset date array using the getIndex on the access item array passing the actual access item on the getIndex of the current accessItem. Someone that is experienced with workflow and this kind of function can help me?

HI,

Its a bit confusing. Can you tell me what exactly is your requirement?

-Abhinov

Hello @s_tartaglione

Can u list down the steps in the workflow that you have implemented to achieve the use case ?

Is my understanding correct ?

A user makes a access request (role/access profile) using form , and each of these request should have a sunset data which user should give (dynamically) ?

If my understanding is correct , help me understand the current approach .(list workflow steps)
There is no ideal do to achieve this , as form fields are not dynamic (we cannot generate new date fields to select sunset for n number of access requests) .
And , we cannot use multiple interactive forms in single workflow , an interactive form cannot work without an interactive trigger .
My rough solution is :
Interactive Trigger to Fill access request dataLoop (input shall be accessItems selected in the interactive form → Form. (this form should read sunset date of one access request)–> HTTP call to submit request using these data

If we are on the same page , can I have a look into the variable name of the access items selection on the form end ? The current problem that you are facing is a parsing issue probably . Once try $.interactiveForm6.formData.selectRole[*] for loop input.

In these days I modified my workflow and my forms.
First of all I give the possibility to the user to select at maximum 3 types of access items (roles or access profile in my case).
The number of access items are passed to another interactive forms in which I’m able to select at maximum 3 sunset dates, but if the user has selected only 2 access profiles or roles, the interactive form shows only 2 sunset date.
The point now is: I have selected the access items and the sunset dates for each of this access items, How I can build the HTTP request to send the approval?


The loop is iterating over the selected role/access profiles, the “Get Access” block allow me to retrieve the id of the role/access profile starting by the name, and than I have the HTTP Request “Submit access request” in which the body contains:

{
    "requestType": "GRANT_ACCESS",
    "requestedFor": {{$.loop.context.interactiveForm6.formData.requestForOthers}},
    "requestedItems": [
        {
            "comment": " ",
            "id": {{$.getAccess.accessItems.id}},
            "removeDate": "2025-07-11T21:23:15.000Z",
            "type": "ROLE"
        }
    ]
}

In this body example I’m trying to see if I’m able to send a request with a fixed sunset date and a fixed type of access item. But I’m receiving this kind of error:

        "errorMessage": "task failed: activity error (type: sp:external:http:v2, scheduledEventID: 11, startedEventID: 12, identity: 1@sp-workflow-worker-stg-eu-central-1-7bb95d84b8-q5wz2@sp-workflow-engine): Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character 'b' after object key:value pair (type: Error Parsing Input, retryable: false): Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character 'b' after object key:value pair (type: SyntaxError, retryable: true)",
        "payload": null

The other point is, once I’ve fixed this error, how i can iterate over the sunset date if multiple roles/access profiles are selected? This last question because actually I’m iterating only on the selected access items, but since I can’t use a loop inside another one, how i can link the sunset date 1 to the first access item and so on?

Hello @s_tartaglione

Try this to resolve the error :

    "requestType": "GRANT_ACCESS",
    "requestedFor": "{{$.loop.context.interactiveForm6.formData.requestForOthers}}",
    "requestedItems": [
        {
            "comment": " ",
            "id": "{{$.getAccess.accessItems.id}}"
,
            "removeDate": "2025-07-11T21:23:15.000Z",
            "type": "ROLE"
        }
    ]
}

To answer your later question , I would like to see the entire workflow preview and forms as well . I want to understand the flow of form data

1 Like

Thanks, it worked fine !! So this is my workflow:



I sent you the branch of the role, I will develop also the other branches. The Interactive Form 4 is the one in which I’m selecting 1, 2 or 3 sunset date, based on the number of the roles selected. I would like to insert these dates related to the linked role, inside the HTTP request

@s_tartaglione

Help me with the following :

  • Is the Interactive form which collects sunset data dynamic ? Will it have the number of input fields based on the number of access items selected in the previous form ?

If two interactive forms are independent , there is no sync and we cannot establish the accessItem-SunsetDate relation.

Can I have a look into the form which collects sunset data

I decided the maximum number of roles that I can select, in my case the maximum is 3. Than I compute the number of roles selected and based on this number in the form of the sunset date selection I’m showing the sunset dates using conditions as you can see:


In the workflow I’m passing the number of roles selected as input variable to this form.