Authentificate using a Token with curl.exe using ZAPI
after using the JUnit import functionality in Zephyr Squad, I have to attach some log files as evidence to the executions created by the JUnit test result upload.
Since I am not a Java developer but more the scripting guy kind, I was looking for examples how to do this in the most direct way.
I found that this is e.g. for uploading an attachment this is to send a POST message to the Jira Server using the ZAPI REST API.
On Windows you can use for example curl.exe.
E.g. curl -D- -u MyUserID -X POST -H "X-Atlassian-Token: no-check" -F "file=@test_time.txt" https://jira-server.mycompany.es/rest/api/2/issue/ABC-11/attachments
Using a 20 line perl script I am able to for example, to retrieve the ids of the test executions via GET requests and then attach specific attachments as evidence to the executions. I have uploaded this script as "20211018_upload_attachments_wip.pl". The script is work in progress and only demonstrated that information can be retrieved via ZAPI API and attachments can be uploaded - nothing else.
I read that within the admin interface of the Zephyr Squad plugin it should be possible to generate an access key that can be used in scripts and can be assigned fine tunes access rights (similiar to github tokens). How can I generate these tokens? How can I use the token in curl.exe.
We installed a newer version of Jira Squar, i.e. 6.2.4.
Wit this version PATs are supported. Each user can create one and use ist e.g. via curl:
curl -X GET -H "Authorization: Bearer <personal_access_token>" -H "Content-Type:multipart/form-data" https://jira-test.intern.hessen.de/rest/zapi/latest/cccccc?ddddd=eeeee
On windows cammandline you have to escape "&" character via "^&".