How to add user to project role using jira rest api and json format to be used

HI ,


Im trying to add user to a specific project role in a project by using JIRA rest api and invoking it throw a power shell ,but when i'm passing json data as below , its giving me "Remote server returned error:400 bad request" error.


 Invoke Rest-Method -Uri  "https://jira url/jira/rest/api/2/project/project id/role/ role id" -Method post -Headers $Headers -Body $data1 -ContentType  "application/json"


Json data

$data= @"


"user" : ["userid/name"]



$data1= $data | ConvertTo-Json


and please let me know whether i have to use PUT/POST functionality to add user to project role and its helpful if any code need to be added to Json .

1 answer

This widget could not be displayed.

Hey Madhuri,

This should work for you

curl -D- -u <username>:<password> -H "Content-Type:application/json" -X POST -d '{"user":["username"]}' -k

curl command.PNG

Using Node.js

//Use .defaults({strictSSL: false}) to by pass SSL certificate or https connection
var request = require('request').defaults({strictSSL: false})

var headers = {
    'Content-Type': 'application/json'

var dataString = '{"user":["cinguva","apawl"]}';

var options = {
    url: '',
    method: 'POST',
    headers: headers,
    body: dataString,
    auth: {
        'user': 'admin',
        'pass': 'password'


function callback(error, response, body) {


request(options, callback);

Hope this helps

Reference threads and this one



The curl command worked for me for setting the project role. How would you unselect a role?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

576 views 25 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you