Hi everyone.
I am using Xray on a an instance of JIRA server. I would like to use the REST API to add an attachment to an XRAY Test step.
Piecing together information from different sources (source1 , source2 , source3 ) , I have settled on the following request:
URL = https://{jira server}/rest/raven/2.0/api/test/{testKey}/steps/{testId}
HTTPRequest = PUT
Body = {
"attachments": {
"add":[
{
"data":"MTAwIHJwbQ0KMjAwIHJwbQ0KMzAwIHJwbQ==",
"filename":"speed points.txt",
"contentType": "text/plain",
}
]
}
}
But that gives the following response
400
{'error': 'Step fields must be provided to create a new test step'}
So then I tried the following request:
URL = https://{jira server}/rest/raven/2.0/api/test/{testKey}/steps/{testId}
HTTPRequest = PUT
Body = {
"fields":{
"Action":"Testing"
},
"attachments": {
"add":[
{
"data":"MTAwIHJwbQ0KMjAwIHJwbQ0KMzAwIHJwbQ==",
"filename":"speed points.txt",
"contentType": "text/plain"
}
]
}
}
which gives the following response:
200
{'step': {'id': 270216, 'attachmentIds': []}, 'warnings': ['Error creating attachment.']}
And just as the response describes, the action field is updated, but no attachment was created!
Can someone help me with creating an attachment through scripts in XRAY Server?
Right now I am trying to maybe see if it is possible to make the same requests in a script the web page makes when creating an attachment. I haven't yet fully explored this option!
Hello, I was just having the same issue and I fixed it by editing the file name in the attachment block. For example:
"attachments": {
"add":[
{
"data":"MTAwIHJwbQ0KMjAwIHJwbQ0KMzAwIHJwbQ==",
"filename":"speed_points.txt",
"contentType": "text/plain"
}
]
}
As it can be seen, I added an underscore in the file name to eliminate spaces. This was the solution that worked for me when I had the same issue. Hope this helps :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I opened the text file and then encoded the contents to base64 using Python.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to use vbscript. Can you send me the code of python how you did it?
chakka.srinivas86@gmail.com
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Edwin Saji Uthuppan and welcome to the community,
as far as I got XRAY documentation right the API doesn´t offer functionality to add attachment to test steps:
https://docs.getxray.app/display/XRAY/Test+Steps+-+REST
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Stefan Salzl
Thanks for the reply!
Look at the above section: It looks like it supports addition of attachments.
There are two issues though, the request has been incorrectly marked as POST instead of PUT and additionally the fact that it doesn't actually work! If you look at the response messages i am getting it doesn't look like there is an issue in recognising my request, but there is an issue in processing my request.
I will try to contact Xpand-IT, but i have to go through a lot of bureaucracy at my company... which is taking time XD
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the docu correctly as PUT:
What I could imagine (especially regarding the error message from your PUT approach) that the JSON array of the attachment is empty before and therefore cannot be „updated“. To check this:
could you try to run the PUT call on a test step that alteady has an attachment?
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Giving File name is fine. How to provide the path and what format need to give?
I have added in request as "filePath": "C:/Srinivas"
Getting error as "Erro instantiating bean. Filed(s) evidences ->add->filePath do not follow the correct format.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Srinivas Ch -- welcome to the community,
I´m not sure if the api request accepts a "filePath" option/property. did you try to use the whole path of the file in your "fileName"?
"attachments": {
"add":[
{
"data":"whatever",
"filename":"C:\andyDirectory\filename.txt",
"contentType": "text/plain"
}
]
}
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Getting response like Error creating attachment.
Given "filename":"C:/Srinivas/Test.txt"
Note: If I give syntax like "C:\Srinivas\Test.txt" it's not accepting
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please provide all details to make it possible for the community to investigate into the situation?
What does your call look like exactly? What exactly is the outpout/response? etc. --> everything that could help to analyze your problem.
Thanks in advance.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can we add evidence for the test under test execution.
Evidence can be either html/txt file.
If yes what count be End point,
Body for the same?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Method : POST
url: jiraserver/rest/raven/1.0/import/execution
what to provide in data field. in documentation it shows some random alphanumeric values
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.