# tower\_cli modify

**URL:** <https://forum.ansible.com/t/tower-cli-modify/28933>\
**Category:** AWX Project\
**Created:** [November 2, 2018, 9:32pm UTC](https://forum.ansible.com/t/tower-cli-modify/28933 "2018-11-02T21:32:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kash](https://avatars.discourse-cdn.com/v4/letter/k/7ab992/32.png) [@Kash](https://forum.ansible.com/u/Kash)\
**Post date:** [November 2, 2018, 9:32pm UTC](https://forum.ansible.com/t/tower-cli-modify/28933/1 "2018-11-02T21:32:53Z")

</div>

Hi,

Looking for pointers on how to use the tower\_cli modify rest api command. I am able to list, create and delete users in a python script but not able to modify existing one.

Thanks,  
Kash

---

<div class="post-metadata">

**Author:** ![shivharsh.nec](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@shivharsh.nec](https://forum.ansible.com/u/shivharsh.nec)\
**Post date:** [November 5, 2018, 10:02am UTC](https://forum.ansible.com/t/tower-cli-modify/28933/2 "2018-11-05T10:02:47Z")

</div>

Hi Kash,

Could you please be a little bit more specific as to what exactly is the issue that you are facing while using the tower-cli modify command?

Below are a few pointers to start with:

**Command Syntax** :

`tower-cli user modify {Identifier} {field_to_modify}={value}`

- Identifier is the filed that is used to lookup the resource. Usually, this is the resource name or the ID.

**Example** : To modify the email of an existing user with ID=23.

`  
[root@anawx ~]# tower-cli user modify 23 [--email=jeff.bezos@example.com](mailto:--email=jeff.bezos@example.com)  
\*\*\* DETAILS: Getting existing record. \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\*\*\* DETAILS: Getting the record. \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
GET [http://anawx.example.com/api/v2/users/23/](http://anawx.example.com/api/v2/users/23/)  
Params: {}

\*\*\* DETAILS: Writing the record. \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
PATCH [http://anawx.example.com/api/v2/users/23/](http://anawx.example.com/api/v2/users/23/)  
Data: {‘email’: u’jeff.bezos@example.com’}

Resource changed.  
== ========== ===================== ========== ========= ============ =================  
id username email first\_name last\_name is\_superuser is\_system\_auditor  
== ========== ===================== ========== ========= ============ =================  
23 jeff.bezos [jeff.bezos@example.com](mailto:jeff.bezos@example.com) Jeff Bezos false false  
== ========== ===================== ========== ========= ============ =================  
`

**Method Syntax:**

`def modify(pk=None, create_on_missing=False, kwargs)`

- **pk** = The primary key for the object to be modified.

- **create\_on\_missing** : Flag if set ‘True’, a new object is created when value for ‘pk’ is not set and the object is not found.

- **kwargs** : It is a key-value pair. When value for pk is not set, this key-value pair is used to lookup an existing object.

To get an insight into the usage of modify method in a script, you may refer to the tower-cli [API reference](https://tower-cli.readthedocs.io/en/latest/_modules/tower_cli/models/base.html#Resource.modify) .

Hope this is helpful !

Thanks,  
Shivharsh

---

<div class="post-metadata">

**Author:** ![Kash](https://avatars.discourse-cdn.com/v4/letter/k/7ab992/32.png) [@Kash](https://forum.ansible.com/u/Kash)\
**Post date:** [November 6, 2018, 6:17pm UTC](https://forum.ansible.com/t/tower-cli-modify/28933/3 "2018-11-06T18:17:26Z")

</div>

Thanks Shivharsh, I got it working now.
