# URI Module "return\_content" not working per the docs

**URL:** <https://forum.ansible.com/t/uri-module-return-content-not-working-per-the-docs/20154>\
**Category:** Ansible Project\
**Created:** [January 8, 2016, 3:30pm UTC](https://forum.ansible.com/t/uri-module-return-content-not-working-per-the-docs/20154 "2016-01-08T15:30:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glenn\_Barnard](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Glenn\_Barnard](https://forum.ansible.com/u/Glenn_Barnard)\
**Post date:** [January 8, 2016, 3:30pm UTC](https://forum.ansible.com/t/uri-module-return-content-not-working-per-the-docs/20154/1 "2016-01-08T15:30:47Z")

</div>

We’re evaluating Ansible and learning how to use it. I’m trying to using Ansible to call the Ansible api’s. I have an issue with the uri module in trying to reference the response from the authtoken API to use in subsequent requests. Per the docs, the return\_content option is supposed to put the json response in the dictionary with the name json. I’m ASSUMING the dictionary is the repository for variables. So, when these tasks run, the second one throws an error saying that the json varaible does not exist.

Can someone tell me how I can reference the response as a variable?

The tasks I wrote is:

- uri:  
url: [https://10.0.0.4/api/v1/authtoken/](https://10.0.0.4/api/v1/authtoken/)  
method: POST  
HEADER\_Content-Type: application/json  
body: ‘{ “username” : “myusername”, “password” : “mypassword” }’  
validate\_certs: no  
return\_content: yes  
register: authentication

- uri:  
url: [https://10.0.0.4/api/v1/users/](https://10.0.0.4/api/v1/users/)  
method: GET  
HEADER\_Authorization: TOKEN {{ json.token }}  
validate\_certs: no  
return\_content: yes

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 8, 2016, 3:35pm UTC](https://forum.ansible.com/t/uri-module-return-content-not-working-per-the-docs/20154/2 "2016-01-08T15:35:21Z")

</div>

Instead of json.token you need to reference the variable that you registered. Such as:

authentication.json.token

`json` is a key off of the registered var from the task.

---

<div class="post-metadata">

**Author:** ![Glenn\_Barnard](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Glenn\_Barnard](https://forum.ansible.com/u/Glenn_Barnard)\
**Post date:** [January 8, 2016, 5:58pm UTC](https://forum.ansible.com/t/uri-module-return-content-not-working-per-the-docs/20154/3 "2016-01-08T17:58:41Z")

</div>

Thanks Matt…A sivel star to you!
