Run REST API on behalf of another user

General information

Since v. 1.7.0 - changes in supported endpoint URLs - JIRA_URL/rest/*

Available for:

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

    • JIRA_URL/rest/*

  • dedicated user groups (since v. 1.7.0 - please check REST API Configuration page)

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

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

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
  • Response in terminal

  • Jira view

Postman example

See how use contextUser in Postman

  • Use in authorization section a user with administrator privileges

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

  • Set body for specific REST and click Send

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

{     "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" }
  • Jira view