The following is my playbook containing a Rest Call
---
-
name: "REST CALL"
hosts: local
tasks:
- name: "REST Call to Get Session ID"
uri:
url: http://192.168.96.172:5300/avxapi/acctmgmt-perform-login?gwkey=f000ca01&gwsource=web
method: POST
body: "{{ lookup('file','empty.json') }}"
body_format: json
return_content: yes
headers:
Content-Type: "application/json"
username: "admin"
password: "Apptest@123"
register: login
- debug:
var: "{{ login }}"
And this is my response
PLAY [REST CALL] *********************************
TASK [Gathering Facts] *********************************************************
ok: [localhost]
TASK [REST Call to Get Session ID] *********************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"<type 'dict'>": "VARIABLE IS NOT DEFINED!"
}
Can anybody find why I'm not getting a proper response? And btw, the body just contains an empty payload. The empty.json looks like this
{"payload":{}}
Best Answer
Please check documentation for
debug
module.var
is for variable name,msg
is for templated value.So: