# Loop over an array and assigning to url within uri module

**URL:** <https://forum.ansible.com/t/loop-over-an-array-and-assigning-to-url-within-uri-module/38710>\
**Category:** Ansible Project\
**Created:** [March 7, 2024, 11:43pm UTC](https://forum.ansible.com/t/loop-over-an-array-and-assigning-to-url-within-uri-module/38710 "2024-03-07T23:43:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohammed\_Reehan](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mohammed\_Reehan](https://forum.ansible.com/u/Mohammed_Reehan)\
**Post date:** [March 7, 2024, 11:43pm UTC](https://forum.ansible.com/t/loop-over-an-array-and-assigning-to-url-within-uri-module/38710/1 "2024-03-07T23:43:22Z")

</div>

Hi Team

i have an array from my previous playbook and saving it as a fact called as

“ansible\_facts”{  
“response\_cloud\_id”: [  
“34eedfc”,  
“6733fdc”  
]  
},

I want to use this response\_cloud\_id for each object as a variable and pass into my URI module in the URL  
[https://cloudzone.net/api/{{](https://cloudzone.net/api/%7B%7B) response\_cloud\_id }}/zone  
how can I assign every element in the array to the URL loop through the array in the URL and make multiple calls till the array length is met?

Please help,

thanks  
Reehan

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [March 8, 2024, 12:35am UTC](https://forum.ansible.com/t/loop-over-an-array-and-assigning-to-url-within-uri-module/38710/2 "2024-03-08T00:35:58Z")

</div>

```auto
- name: Run uri in a loop
  ansible.builtin.uri:
    url: [https://cloudzone.net/api/](https://cloudzone.net/api/){{ item }}/zone
  loop: '{{ response_cloud_id }}'

```

See [https://docs.ansible.com/ansible/latest/playbook\_guide/playbooks\_loops.html#standard-loops](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_loops.html#standard-loops)
