View Only
  • 1.  REST to update user data

    Posted 4 days ago

    I am currently using  py_jama_rest_client.client  for api calls against my running instance. Using  users = client.get_users()  I am able to successfully get my user records. After targeting a specific record to be updated:    {'id': 105, 'username': '', 'firstName': 'Dev', 'lastName': 'Test', 'email': '', 'phone': '', 'title': '', 'location': '', 'licenseType': 'FLOATING', 'active': True, 'authenticationType': {'id': 2, 'name': 'IdP'}, 'type': 'users'}

    I would like to use    client.put_user()   to update the edited username field. Following Jama's definition:         put_user ( self, user_id, username, password, first_name, last_name, email, phone=None, title=None, location=None)

    However, this generates an API response error:

         You must specify an authentication type when the authentication mode is Basic+IdP

    Only the prescribed parameters in the above definition are accepted. But the shape of our user data is different.

    As far as I can tell, API IDs are different than UserIds, so the ability to patch based on the API ID is not an option.


    1. If not py_jama_rest_client, what can be used programmatically to update username/email? I can do this through the interactive Jama REST API, but would like to create an app for bulk changes.
    2. Can user data (username, email) be PUT with requests (Python) or fetch (JavaScript)?  Are there examples including oauth?

    lynne banki
    Blue Origin
    Kent WA

  • 2.  RE: REST to update user data

    Posted 2 days ago
    Edited by Martha Fiske 2 days ago
    Hi Lynne,

    I had some trouble using the py_jama_rest_client so I used import requests.

    I was able to update items with the following code:
    Note - it was recommended in an article I read to lock the item while making the update.


    #get existing item
    lock_url = url+'rest/v1/items/'+str(data['jama_id'])+'/lock'
    response = requests.put(lock_url,json={"locked":True},auth=(username, secret),headers=headers)
    #get item
    item_url = url+'rest/v1/items/'+str(data['jama_id'])
    item_response = requests.get(item_url,auth=(username, secret),headers=headers)
    item = item_response.json()

    #update fields 
    item['data']['fields'][<field to update>] = data[<new value>]. 
    response = requests.put(item_url,json=item['data'],auth=(username, secret),headers=headers)
    # unlock item
    response = requests.put(lock_url,json={"locked":False},auth=(username, secret),headers=headers)

    Hope this helps.​​

    Martha Fiske
    Lucid Motors

  • 3.  RE: REST to update user data

    Posted yesterday
    Thank you, Martha! I will let you know how it goes.

    lynne banki
    Blue Origin
    Kent WA