Thanks for your feedback. But there is a problem in 'URI' module. In "URI" module, there is no way to pass "access token". Access token is required here as the url is OAUTH2.0 enabled.
You can get access token by passing client id and secret but you cannot pass it to uri module to get the response back. That's why I am trying to use curl command and sending the JSON body. Best Wishes, Bikram On Fri, Mar 15, 2019 at 11:21 PM Kai Stian Olstad < [email protected]> wrote: > On 15.03.2019 23:55, bikram40 wrote: > > I defined a json variable in vars section and want to pass it as body in > > curl command as below: > > As Sudheer mention you should take a look at the uri module. > > > > > > vars: > > > > - paydata: {"status":"complete","message":"successfully > > > > completed","actions":["close ticket"]} > > This is not json in Ansible it's a dict. > > > > - local_action: command curl -X PUT -i -H "Content-Type:application/json" > > https://ansibledev.corp.xxxx.com:8443/api/job/{{ ticket }} -k --data "{{ > > paydata }}" completed","actions":["close ticket"]}' --header > > > > > > > > But here is the error I am getting. Seems "paydata" is not passed as > > expected. > > > > > > fatal: [10.225.240.39 -> localhost]: FAILED! => {"changed": true, "cmd": > > ["curl", "-X", "PUT", "-i", "-H", "Content-Type:application/json", " > > https://gns-ansible-dev.corp.xxx.com:8443/api/job/CRQmattcheng22", "-k", > > "-d", "{ustatus:", "ucomplete,", "umessage:", "usuccessfully completed,", > > "uactions:", "[uclose ticket]}", > > To make a dict to be formated as json you need to use the to_json filter > > https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#filters-for-formatting-data > > > -- > Kai Stian Olstad > > -- > 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 post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/a096b6cb-4b69-6420-2050-057b98addb1b%40olstad.com > . > For more options, visit https://groups.google.com/d/optout. > -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEFfMJRtZ_UbiF17GX-KPLoe%2B5W_Erj5ebMNLCp_p98z9Wh4Nw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
