Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents



General information


Info

Available for:

 - JIRA administrator - includes all of the following REST API:

      - JIRA_URL/rest/api/* 

 

  - JIRA_URL/rest/extender/*
      - JIRA_URL/rest/servicedeskapi/*
      - JIRA_URL/rest/scriptrunner/*

- dedicated user groups (since v. 1.

39.*)      - JIRA_URL/rest/keplerrominfo/* (since v. 1.40.*.1

7.0 - please check REST API Configuration page)

 - dedicated user groups ( since v. 1.7.0 - please check REST API Configuration page)changes in supported endpoint URLs - JIRA_URL/rest/*



How it’s works

It’s simple, just add into REST API request new header parameter contextUser containing username in the context of which we want to execute REST API.



CURL example

See how use contextUser in unix curl command


Expand

1. Create CURL command (admin credential, new header contextUser set to user) and run it.

Code Block
languagebash
themeMidnight
curl -u admin:admin -H "Content-Type: application/json" -H "contextUser: user" --data '{"body":"REST API Extender works good :) - CURL Example"}' -X POST http://localhost:2990/jira/rest/api/2/issue/PROJA-1/comment


2. Response in terminal

Code Block
languagebash
themeMidnight
"self":"http://localhost:2990/jira/rest/api/2/issue/10000/comment/10102","id":"10102","author":{"self":"http://localhost:2990/jira/rest/api/2/user?username=user","name":"user","key":"JIRAUSER10100","emailAddress":"user@jira.user.pl","avatarUrls":{"48x48":"https://www.gravatar.com/avatar/34c897cf89d2c13ed8dad7ca51ea0edf?d=mm&s=48","24x24":"https://www.gravatar.com/avatar/34c897cf89d2c13ed8dad7ca51ea0edf?d=mm&s=24","16x16":"https://www.gravatar.com/avatar/34c897cf89d2c13ed8dad7ca51ea0edf?d=mm&s=16","32x32":"https://www.gravatar.com/avatar/34c897cf89d2c13ed8dad7ca51ea0edf?d=mm&s=32"},"displayName":"user","active":true,"timeZone":"Europe/Warsaw"},"body":"test","updateAuthor":{"self":"http://localhost:2990/jira/rest/api/2/user?username=user","name":"user","key":"JIRAUSER10100","emailAddress":"user@jira.user.pl","avatarUrls":{"48x48":"https://www.gravatar.com/avatar/34c897cf89d2c13ed8dad7ca51ea0edf?d=mm&s=48","24x24":"https://www.gravatar.com/avatar/34c897cf89d2c13ed8dad7ca51ea0edf?d=mm&s=24","16x16":"https://www.gravatar.com/avatar/34c897cf89d2c13ed8dad7ca51ea0edf?d=mm&s=16","32x32":"https://www.gravatar.com/avatar/34c897cf89d2c13ed8dad7ca51ea0edf?d=mm&s=32"},"displayName":"user","active":true,"timeZone":"Europe/Warsaw"},"created":"2019-11-01T15:10:25.658+0100","updated":"2019-11-01T15:10:25.658+0100"}


and into JIRA you can see this



Postaman example

See how use contextUser in Postman


Expand

1. Use in authorization section a user with administrator privileges


2. In context section add new header contextUser. Enter in value another user name, for example i used user named user


3. Set body for specific REST and click Send


4. Comment was added to issue for user user. Response body looks like this:

Code Block
{
    "self": "http://localhost:2990/jira/rest/api/2/issue/10000/comment/10125",
    "id": "10125",
    "author": {
        "self": "http://localhost:2990/jira/rest/api/2/user?username=user",
        "name": "user",
        "key": "user",
        ...
    },
    "body": "REST API Extender works good :)",
    "updateAuthor": {
        "self": "http://localhost:2990/jira/rest/api/2/user?username=user",
        "name": "user",
        "key": "user",
        "emailAddress": "user@user.user",
        ...
    },
    "created": "2017-08-04T20:50:23.351+0200",
    "updated": "2017-08-04T20:50:23.351+0200"
}


and into JIRA you can see this



Include Page
REST API Configuration
REST API Configuration