# Trouble with expect:  passing creds

**URL:** <https://forum.ansible.com/t/trouble-with-expect-passing-creds/21568>\
**Category:** Ansible Project\
**Created:** [May 25, 2016, 8:12pm UTC](https://forum.ansible.com/t/trouble-with-expect-passing-creds/21568 "2016-05-25T20:12:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Rogers](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Jeff\_Rogers](https://forum.ansible.com/u/Jeff_Rogers)\
**Post date:** [May 25, 2016, 8:12pm UTC](https://forum.ansible.com/t/trouble-with-expect-passing-creds/21568/1 "2016-05-25T20:12:08Z")

</div>

I'm getting the following error:

...... "msg": "argument responses is of type \<type 'list'\> and we were unable to convert to dict"

I'm trying to do this.

- name: Name of the thing I'm doing  
&nbsp;&nbsp;hosts: '{{ target }}'  
&nbsp;&nbsp;serial: 1  
&nbsp;&nbsp;vars\_prompt:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: "UserName"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prompt: "User Name "  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private: yes

&nbsp;&nbsp;&nbsp;&nbsp;- name: "UserPWD"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prompt: "Password "  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private: yes

- expect:  
&nbsp;&nbsp;&nbsp;&nbsp;echo: yes  
&nbsp;&nbsp;&nbsp;&nbsp;command: /use/bin/mybinary argument  
&nbsp;&nbsp;&nbsp;&nbsp;responses:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- 'Username': "{{ UserName }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- 'Password': "{{ UserPWD }}"

---

<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:** [May 26, 2016, 4:28pm UTC](https://forum.ansible.com/t/trouble-with-expect-passing-creds/21568/2 "2016-05-26T16:28:16Z")

</div>

Your `responses` argument needs to be a hash/dict, not an array/list:

- expect:  
echo: yes  
command: /use/bin/mybinary argument  
responses:  
‘Username’: “{{ UserName }}”  
‘Password’: “{{ UserPWD }}”

The only change above is removing the `- ` from before each question/answer.

---

<div class="post-metadata">

**Author:** ![Jeff\_Rogers](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Jeff\_Rogers](https://forum.ansible.com/u/Jeff_Rogers)\
**Post date:** [June 3, 2016, 9:19pm UTC](https://forum.ansible.com/t/trouble-with-expect-passing-creds/21568/3 "2016-06-03T21:19:49Z")

</div>

Excellent, that fixed it, thank you. I can't seem to get a become: / become\_user: to work in the -expect task now. Had to pass it in as a global.
