Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 27 Next »


Introduction

User Export for Jira app has a build in REST endpoint that can be used to get, create, update and delete Jira User Properties. This can be very useful if you want to bulk update Jira user properties for a large set of Jira users.

The REST endpoint is available when User Export for Jira app 1.2.0 or greater is installed in Jira. It can be found under <jira-base-url>/rest/jirauserexport/1.0/userproperties.

SECURITY

Only Jira users with Jira Admininstrators or Jira System Administrators global permission can access this endpoint.


SUPPORT

Please use Netic A/S Service Desk if you have any questions or difficulties using the server endpoints for Jira user properties.


Operation

HTTP Method

Authentication

REST endpoint

JSON Payload

Get Jira user property

GET

BASIC

<jira-base-url>/rest/jirauserexport/1.0/userproperties


{"username": "admin","userPropertyKey": "mobile"}


Create Jira user property

POST

BASIC

<jira-base-url>/rest/jirauserexport/1.0/userproperties


{"username": "admin","userPropertyKey": "mobile", "userPropertyValue":"+4511223344"}


Update Jira user property

PUT

BASIC

<jira-base-url>/rest/jirauserexport/1.0/userproperties


{"username": "admin","userPropertyKey": "mobile", "userPropertyValue":"+4511223344"}


Delete Jira user property

DELETE

BASIC

<jira-base-url>/rest/jirauserexport/1.0/userproperties


{"username": "admin","userPropertyKey": "mobile"}


Get user property for a given user

Python 2 code for getting a Jira user property

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Get user properties for Jira user - HTTP GET
'''
import json
import urllib2
import base64

BASIC_AUTH = "Basic " + base64.b64encode("admin:admin")
HEADERS = {"Content-type": "application/json","Accept":"application/json","Authorization": BASIC_AUTH}
URL = "http://localhost:2990/jira/rest/jirauserexport/1.0/userproperties"

def get_user_property(user_name, property_key, url):
    data = json.dumps({
        "username": user_name,
        "userPropertyKey": property_key
    })
    request = urllib2.Request(url, data, HEADERS)
    request.get_method = lambda: "GET"
    try:
        contents = urllib2.urlopen(request).read()
        if contents:
            print contents
    except urllib2.HTTPError as e:
        print e.code


get_user_property(user_name="admin", property_key="mobile", url=URL)


Create user property for a given user

Python 2 code for creating a Jira user property

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Create user properties for Jira user - HTTP POST
'''
import json
import urllib2
import base64

BASIC_AUTH = "Basic " + base64.b64encode("admin:admin")
HEADERS = {"Content-type": "application/json","Accept":"application/json","Authorization": BASIC_AUTH}
URL = "http://localhost:2990/jira/rest/jirauserexport/1.0/userproperties"

def create_user_property(user_name, property_key, property_value, url):
    data = json.dumps({
        "username": user_name,
        "userPropertyKey": property_key,
        "userPropertyValue": property_value
    })
    request = urllib2.Request(url, data, HEADERS)
    request.get_method = lambda: "POST"
    try:
        contents = urllib2.urlopen(request).read()
        if contents:
            print contents
    except urllib2.HTTPError as e:
        print e.code


create_user_property(user_name="admin", property_key="mobile", property_value="+4511223344", url=URL)


Update user property for a given user

Python 2 code for updating a Jira user property

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Update user properties for Jira user - HTTP PUT
'''
import json
import urllib2
import base64

BASIC_AUTH = "Basic " + base64.b64encode("admin:admin")
HEADERS = {"Content-type": "application/json","Accept":"application/json","Authorization": BASIC_AUTH}
URL = "http://localhost:2990/jira/rest/jirauserexport/1.0/userproperties"

def update_user_property(user_name, property_key, property_value, url):
    data = json.dumps({
        "username": user_name,
        "userPropertyKey": property_key,
        "userPropertyValue": property_value
    })
    request = urllib2.Request(url, data, HEADERS)
    request.get_method = lambda: "PUT"
    try:
        contents = urllib2.urlopen(request).read()
        if contents:
            print contents
    except urllib2.HTTPError as e:
        print e.code


update_user_property(user_name="admin", property_key="mobile", property_value="+4566996699", url=URL)


Delete user property for a given user

Python 2 code for deleting a Jira user property

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Delete user properties for Jira user - HTTP DELETE
'''
import json
import urllib2
import base64

BASIC_AUTH = "Basic " + base64.b64encode("admin:admin")
HEADERS = {"Content-type": "application/json","Accept":"application/json","Authorization": BASIC_AUTH}
URL = "http://localhost:2990/jira/rest/jirauserexport/1.0/userproperties"

def delete_user_property(user_name, property_key, url):
    data = json.dumps({
        "username": user_name,
        "userPropertyKey": property_key
    })
    request = urllib2.Request(url, data, HEADERS)
    request.get_method = lambda: "DELETE"
    try:
        contents = urllib2.urlopen(request).read()
        if contents:
            print contents
    except urllib2.HTTPError as e:
        print e.code


delete_user_property(user_name="admin", property_key="mobile", url=URL)



  • No labels