Share Request using custom trigger overwrites existing shares

Share Request using custom trigger overwrites existing shares

Hi,

I've created a powershell script that takes the mail address typed in the Cc field, and shares the request with this person. This works fine as long as the tech/user only types one mail address in the field.

When we type e.g. 3 addresses in the Cc field separated by "," the script works, but adds the shares one at a time. And each time the existing share is deleted.

So if the Cc field consists of: user1@domain.com, user2@domain.com, user3@domain.com the following happens:

1) Request is shared with user1
2) The share is deleted and then shared with user2
3) The share is deleted and then shared with user3
Result: the request is only shared with user3

How do I go about ADDING shares instead of replacing them?

Here's the main parts of the code that I use (Powershell):



$inputReq = @"
{
"share": {
"users": [
{"email_id": "$cc"}
]
}
}
"@

$paramsStat2 = @{INPUT_DATA=$inputReq;format='json'}

$header = @{TECHNICIAN_KEY=$techkey}

Invoke-RestMethod -Method PUT -Uri $url3 -Headers $header -Body $paramsStat2 -ContentType "application/x-www-form-urlencoded"


I hope someone can help. I am thinking maybe it has to do with the method (PUT) that has to be "ADD" or "UPDATE" or something instead...
/Rasmus

                  New to ADSelfService Plus?