I see. Thank you! El Monday, February 21, 2022 a la(s) 7:16:35 PM UTC-6, [email protected] escribió:
> 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". > > On Tuesday, February 22, 2022 at 10:37:08 AM UTC+10 [email protected] > wrote: > >> 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" " >> } >> >> >> El Monday, February 21, 2022 a la(s) 6:21:54 PM UTC-6, [email protected] >> escribió: >> >>> > 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 >>> [2] >>> https://docs.ansible.com/ansible/devel/collections/ansible/builtin/default_callback.html#parameter-result_format >>> >>> On Tuesday, February 22, 2022 at 10:01:20 AM UTC+10 [email protected] >>> wrote: >>> >>>> >>>> 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" >>>> method: GET >>>> validate_certs: no >>>> return_content: yes >>>> headers: >>>> Authorization: 'Token token="{{ token }}"' >>>> register: output >>>> >>>> >>>> Regards, >>>> >>>> Josue. >>>> >>> -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b2c747e7-4f8d-4af6-b9ec-daa2495783e0n%40googlegroups.com.
