How do you get a web request to work in an automation rule?
Asked by Tim Bonney:

I am trying to build what I thought would be a simple automation rule with a web request to obtain the email addresses of the members of a project role (to be used in a later step of the same rule to send that group an email message). Nothing I try works and I have been unable to find the resolution through my own research, so I am hopeful that someone here has experienced the issue and can provide guidance.

*** ** * ** ***

I have formatted the request as follows:

URL: https://\<OURCOMPANY\>.atlassian.net/rest/api/3/project/10019/role/10005/members

Method: GET

Body: {} Empty

Delay execution: Checked

Header: Content-Type = application/json

*** ** * ** ***

However, when I provide an issue key from that project and attempt the validate button, it fails with a 404 not found Response and tells me the fist one below in the Response Payload:

If I take the "members" off the end and try, it, it tells me the project is not found, but I know for a fact that I am using the proper project id and role id, which I've shown as the second one below.

***(\* NOTE - I also tried both versions using project key instead of project id, but that gives the same results.)***

```
{  "message": "null for uri: https://jkseva.atlassian.net/rest/api/3/project/10019/role/10005/members",  "status-code": 404}
```

```
{  "errorMessages": [    "No project could be found with id '10019'."  ],  "errors": {}}
```


Answers:
author: Tim Bonney
body: Thanks [@Jovin](/t5/user/viewprofilepage/user-id/5104734)

I tried this though, but am still getting a 404 error. Any further suggestions? Thanks.![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/332428i850528D795305353/image-size/large?v=v2&px=999 "image.png")

comments: author: Jovin
body: Hey [@Tim Bonney](/t5/user/viewprofilepage/user-id/5149065)

Cool I see the issue here with that screenshot! I should have asked for one earlier.

1. You need to type in the Key/Value for every header, including the Content-Type, so make sure you have:
   1. Key: Content-Type
   2. Value: application/json
      1. It won't accept capitalized like in the example
2. I couldn't find the end-point you're trying to query, but I can see you want the members email addresses of the project role, so here would be the API you want to query: <https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-role-actors/#api-rest-api-3-role-id-actors-get>
   1. Actors are members in this regard, but it also returns the groups, so it will not necessarily always be returning you members
   2. For this case you'd need to then work through with some "for each" looping on the resulting data to essentially go:
      1. IF group THEN
      2. API call for members of group using this end point: <https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-groups/#api-rest-api-3-group-member-get>
      3. IF user THEN
      4. you have the user

Let me know if anything else is unclear; I've not worked on the iterating over the returned data but give it a shot and if you get stuck I can try take a look later.

See below a screenshot of my config working with appropriate authorization \& content-type headers:

![api.png](https://community.atlassian.com/t5/image/serverpage/image-id/332434iFD81333D23684250/image-size/large?v=v2&px=999 "api.png")


author: Tim Bonney
body: Thanks again [@Jovin](/t5/user/viewprofilepage/user-id/5104734) but even after changing application/json to lower case, I am still getting 404 error...


author: Jovin
body: Hey [@Tim Bonney](/t5/user/viewprofilepage/user-id/5149065)

Don't forget to change the URL you're using as well. The one you have looks to not exist and the correct ones (get members of a project role) was also linked above.

If you're still having issues send through a new screenshot and we'll troubleshoot some more!


author: Tim Bonney
body: Hi [@Jovin](/t5/user/viewprofilepage/user-id/5104734) .

Thanks again for all your guidance. When I use the url: <https://xyz.atlassian.net/rest/api/3/role/10005/actors>, I get a successful response, with a payload of actors, but no actual actors are listed:

```
{  "actors": []}
```

When I use the full url you provided previously, it still gives me a 404 (<https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-role-actors/#api-rest-api-3-role-id-actors-get>), but I am pretty sure that is because I am supossed to modify the part of the string following the "/rest/v3" with different text specifying my distinct values, but no iteration of that that I have tried works.

So, if I have the basic "actors" call working (but with empty results), what do I now need to change in order to further designate the specific project for which I want to identify the actors associated with that project role?

Thanks again for you guidance! This assistance is GREATLY appreciated.


author: Jovin
body: Hey [@Tim Bonney](/t5/user/viewprofilepage/user-id/5149065)

On the right track! That URL that gives you no actors is the correct usage, glad we got it authenticated and working. That other URL I provided was simply the documentation so you're on the right track here.

I was off-track though; I gave you the find default actors for the project role, my bad! The correct one you want would be: <https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-roles/#api-rest-api-3-project-projectidorkey-role-id-get>

You just need to change your URL that you're point to in your automation to:

```
/rest/api/3/project/{projectIdOrKey}/role/{id}
```

The automation I suggested to iterate over the data would need tweaking to get where you want, but should help provide some basic sguidance!


author: Tim Bonney
body: Thanks again [@Jovin](/t5/user/viewprofilepage/user-id/5104734)

Looks like it was the "/members/" on the tail of my url string that was causing issues.

Now, I'll need to work on the parsing as you suggested, but I may need additional call(s) first because the actor content returned does not include email address.

I'm not sure I'll get the time to work on this today or tomorrow, but whenever I do, I will update this thread to let you know the outcome.

Thank you once again for all your assistance in this process. I really appreciate your willingness to help out a newbie.


author: Jovin
body: All newbies at some point! Hopefully you've got what you need to keep playing around!


author: Jovin
body: Hey Tim,

Have you tried replacing the 10019 with the key of the project? (e.g. if the issue key is KEY-123 your project key is KEY)? It looks like it's having issues with the numeric id.

comments: author: Tim Bonney
body: Hi Javin.

Yes, unfortunately, I have attempted it both ways but get the same results with either approach.


author: Rupa Goyal
body: Was any solution found for this? I am facing the same issue.


author: Tim Bonney
body: Sorry Rupa, but no. I am still struggling to figure out why it is happening. As you can see here, I only received one response to this post, but they had misread my original post.


author: Rupa Goyal
body: Hey Tim, using a new API key worked for me.  
Encoded it using:   
echo -n user@example.com:api_token_string \| base64


author: Tim Bonney
body: Thank you Rupa. I can try that, but am not sure what you mean...So, from my original post, in the URL string, I would replace "/api/3/", with "/api_token_string \| base64"?


author: Rupa Goyal
body: The change will be in the Authorization Header.  


author: Jovin
body: Ah [@Tim Bonney](/t5/user/viewprofilepage/user-id/5149065)

I see now - I missed a key thing, you didn't add the Authorization header into the parameters as well.

[@Rupa Goyal](/t5/user/viewprofilepage/user-id/5306008) is correct, you need to create an API key and then encode it as Base64. If you're windows based like me you can follow these:

* Get the right API token following these instructions: <https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/>
* Now, for encoding into Base64 via PowerShell on Windows you can do the below, be sure to replace "email:token" e.g. "jovin@domain.com:TOKENHERE"

```
$Text = "email:token"
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($Text)
$EncodedText = [Convert]::ToBase64String($Bytes)
$EncodedText
```

* Copy that text that is output and put it into one of the headers in your automation, so you headers should be:
  * Content-Type
    * application/json
  * Authorization
    * Basic BASE64TOKEN

Hopefully that helps!


author: Tim Bonney
body: Thank you [@Jovin](/t5/user/viewprofilepage/user-id/5104734) .

I appreciate both yours and [@Rupa Goyal](/t5/user/viewprofilepage/user-id/5306008) 's assistance!

I apologize for so many questions, but I am still a beginner here.

I think I understand what you are saying. However, with regards to the API token, we are using Jira Cloud, so do I still attempt the process you've indicated, even though this would not be on a local server? I ask because when you say "...via PowerShell on Windows you can ...", it makes me think I am doing this process locally, so am not sure this still applies if our jira instance is in the cloud.

Thanks.


author: Jovin
body: No worries at all, [@Tim Bonney](/t5/user/viewprofilepage/user-id/5149065) , it gave me headaches when I started with APIs too!

So, the API generation is done via the instructions and that's on your Cloud instance. You copy down that API token and do the PowerShell part on your local machine, if you don't have PowerShell, you could try find alternatives for macOS or others by googling "how to encode string as base64".

I wouldn't recommend doing an online tool for it just in case there's a possible security issue!

Then you can input that information into your automation rule, see an example screenshot below:

![headers.png](https://community.atlassian.com/t5/image/serverpage/image-id/332415i89ABA940C596C465/image-size/large?v=v2&px=999 "headers.png")


Tags: cloud

jira-service-management

jira-service-management-cloud