Script and Testing steps

ARTIFACTORY: Python script to create user

AuthorFullName__c
Sunil Varghese
articleNumber
000005695
ft:sourceType
Salesforce
FirstPublishedDate
2023-04-27T15:31:17Z
lastModifiedDate
2023-04-27
VersionNumber
1
  1. Copy the below to a .py extension file (in our e.g it is set as file.py)
  2. Open the file in an editor and change the bearer token(inputvalueforbearertoken) based on the access token you are generating in your Artifactory instance and all the values marked as “?” needs to be changed too to match your needs. “artinstanceurl” needs to be replaced with your Artifactory URL.
  3. Go to the location of the file in a command or terminal window and use the following command “python3 file.py”. 
    import requests
    headers = {'Content-type': 'application/json', 'Authorization': 'Bearer inputvalueforbearertoken'}
    jsondata = '{"username": "?", "password": "?", "email": "?","groups": ["?"],"admin": false,"profile_updatable": true,"internal_password_disabled": false,"disable_ui_access": false}'
    url = "https://artinstanceurl/access/api/v2/users"
    y = requests.post(url, jsondata, headers=headers)
    print(y.text)