I'm trying to run AWX job template from REST API using Python. It is working fine when just running job template without any arguments, but I will need to specify the target hosts in the execution. When using get method I can see there is a 'limit' argument. Unfortunately when I run the code with python script.py job_id I'm getting the ignored field for limit: b'{"job":2133,"ignored_fields":{"limit":"server-PRC-05"},"id":2133,"type":"job","url":" etc.. I wasn't able to find working example for this. Please find my python code below:
import sys
import requests
import json
templateid=sys.argv[1]
from requests.auth import HTTPBasicAuth
headers = {'content-type': 'application/json'}
data_new = {'limit': 'server-PRC-05'}
res = requests.post('http://awx_host/api/v2/job_templates/'+templateid+'/launch/',
verify=False, auth=HTTPBasicAuth('user', 'password'), data=json.dumps(data_new), headers=headers)
print (res.content)