# Quotes inside URI header

**URL:** <https://forum.ansible.com/t/quotes-inside-uri-header/36352>\
**Category:** Ansible Project\
**Created:** [February 22, 2022, 12:01am UTC](https://forum.ansible.com/t/quotes-inside-uri-header/36352 "2022-02-22T00:01:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![1793](https://avatars.discourse-cdn.com/v4/letter/1/898d66/32.png) [@1793](https://forum.ansible.com/u/1793)\
**Post date:** [February 22, 2022, 12:01am UTC](https://forum.ansible.com/t/quotes-inside-uri-header/36352/1 "2022-02-22T00:01:20Z")

</div>

Hi there,

I have a scenario where I have to pass a token in the URI Authorization header, but it must be enclosed in double quotes as per my endpoint’s requirement. When I attempt to do it, the quotes are being parsed into JSON and the token is enclosed by backslashes.

How can I avoid Ansible evaluating those manually added double quotes? Here’s my URI task snippet.

- name: Login  
uri:  
url: “[test.com](http://test.com)”  
method: GET  
validate\_certs: no  
return\_content: yes  
headers:  
Authorization: ‘Token token=“{{ token }}”’  
register: output

Regards,

Josue.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [February 22, 2022, 12:21am UTC](https://forum.ansible.com/t/quotes-inside-uri-header/36352/2 "2022-02-22T00:21:54Z")

</div>

> When I attempt to do it, the quotes are being parsed into JSON and the token is enclosed by backslashes.

Why do you believe this is the case, if it’s due to the backslashes appearing in the task output that’s just due to the output being encoded as json. The literal value is what that json represents not the json literally. Using the yaml callback [1] is a nice way to get a more “literal” value back in the output, although it’s not perfect. The yaml formatting has also been introduced in the default callback in ansible-core 2.13 [2] through the result\_format option but that hasn’t been released yet.

[1] [https://docs.ansible.com/ansible/latest/collections/community/general/yaml\_callback.html](https://docs.ansible.com/ansible/latest/collections/community/general/yaml_callback.html)  
[2] [https://docs.ansible.com/ansible/devel/collections/ansible/builtin/default\_callback.html#parameter-result\_format](https://docs.ansible.com/ansible/devel/collections/ansible/builtin/default_callback.html#parameter-result_format)

---

<div class="post-metadata">

**Author:** ![1793](https://avatars.discourse-cdn.com/v4/letter/1/898d66/32.png) [@1793](https://forum.ansible.com/u/1793)\
**Post date:** [February 22, 2022, 12:37am UTC](https://forum.ansible.com/t/quotes-inside-uri-header/36352/3 "2022-02-22T00:37:08Z")

</div>

I understand. In that case, beyond that output appearance, it’s the actual value that I thought was being encoded/modified. That’s the one I need in double quotes. The header value must look like this:

“headers”: {

“Authorization”: "Token token=“1234” "

}

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [February 22, 2022, 1:16am UTC](https://forum.ansible.com/t/quotes-inside-uri-header/36352/4 "2022-02-22T01:16:35Z")

</div>

If it’s showing “Authorization”: “Token token="1234"” then that’s to be expected. The json formatting of the output needs to escape the inner double quotes to make it valid json. The literal value sent to the module is still Token token=“1234”.

---

<div class="post-metadata">

**Author:** ![1793](https://avatars.discourse-cdn.com/v4/letter/1/898d66/32.png) [@1793](https://forum.ansible.com/u/1793)\
**Post date:** [February 22, 2022, 1:30am UTC](https://forum.ansible.com/t/quotes-inside-uri-header/36352/5 "2022-02-22T01:30:01Z")

</div>

I see. Thank you!
