I have following code which creates subtask in JIRA
inf = open('/var/lib/rundeck/output.txt')
for line in inf:
print line
headers = {'Content-Type': 'application/json',}
data = '{"fields":{"project":{"key":"TECH"},"parent":{"key":line},"summary":"Create AD List ","description":"","issuetype":{"name":"Sub-task"},"customfield_10107":{"id":"10400"}}}'
response = requests.post('https://jira.company.com/rest/api/latest/issue/', headers=headers, data=data, auth=('user', 'pass'))
inf.close()
i have a file (output.txt), python for every line found (TECH-XXX) printss all lines, it should trigger script above.
when i hard-code key "key":"TECH-1147" instead of "key":line script generates subtask, but when substituting variable (line), nothing happens
Ouptut.txt:
TECH-1234
TECH-1345
.........
i convereted this code:
curl -D- -u: user:Pass -X POST --data "{\"fields\":{\"project\":{\"key\":\"TECH\"},\"parent\":{\"key\":\"$project\"},\"summary\":\"Create AD List of all Active Users\",\"description\":\"some description\",\"issuetype\":{\"name\":\"Sub-task\"},\"customfield_10107\":{\"id\":\"10400\"}}}" -H "Content-Type:application/json" https://company.com/rest/api/latest/issue/
using this https://curl.trillworks.com/
tried also {"key":'"' + line + '"'}
and getting {u'errorMessages': [u'The issue no longer exists.'], u'errors': {}}
Issue is TECH-1247 (variable) which definitely exists
data = "%s" % lineand put it "key":data but the same, when hard-code it it worksresponse.json()(orjson.dumps(resp_json)) to see what the response looks like? Maybe it will show an error.