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 12 Current »


Python 3 code

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import base64

JIRA_URL = "http://localhost:2990/jira/plugins/servlet/jirauserexport/admin/xml"
BASIC_AUTH = "Basic " + base64.b64encode(b"admin:admin").decode("utf-8")
HEADERS = {"Content-type": "application/x-www-form-urlencoded", "Authorization": BASIC_AUTH}
FILE_NAME = "jira-users.xml"


def call_export_endpoint(url, payload, headers):
    r = requests.post(url=url, data=payload, headers=headers)
    print("Response status code: " + str(r.status_code))
    return r._content


def write_to_file(file_data, file_name):
    with open(file_name, 'w') as file:
        file.write(file_data.decode("utf-8"))
    print("File " + file_name + " was written to disk!")


if __name__ == "__main__":
    body = {
        "userexport_searchstring": "admin",
        "userexport_activeUsers": True,
        "userexport_inactiveUsers": True,
        "userexport_download": True,
        "userexport_group": "",
        "userexport_application": ""}
    final_result = call_export_endpoint(url=JIRA_URL, payload=body, headers=HEADERS)
    write_to_file(file_data=final_result, file_name=FILE_NAME)


cURL example

cURL command
# Call XML export
curl -vk -u admin:admin -H "Content-Type: application/x-www-form-urlencoded" \
"http://localhost:2990/jira/plugins/servlet/jirauserexport/admin/xml" \
-d "userexport_searchstring=&userexport_activeUsers=true&userexport_inactiveUsers=true" >> jira-users.xml



  • No labels