Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

2 issues with REST API

Florent Delvaille
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 3, 2018

Hi,

I'm currently doing some migrations of issues from one Jira Cloud instance to our private Jira instance.

 

It's basically working well, but I got 2 issues I can't fix … Hopefully somebody here will be able to help me :)

 

So, my script is in Ruby, and I'm using RestClient for GET/POST methods.

 

1) Unable to correctly  set Assignee + Author of Comment

Here is my code to post_json (it's good as it works for plenty of stuffs for me):

def post_json(instance,location, json_data)
url,user,password = get_instance_infos(instance)
puts url + location
response = RestClient::Request.new(
:method => :post,
:url => url + location,
:user => user,
:password => password,
:headers => {
:accept => :json,
:content_type => :json
},
:payload => json_data
).execute
if !response.empty?
results = JSON.parse(response.to_str)
return results
end
end

When executing it, here is what I get:

{"fields":{"project":{"key":"EX"},"issuetype":{"id":"27"},"summary":"TEST - PRIVE consolidatie carriere","description":"TEST van de volgende issues\r\nPENSA 4\r\nPENSA 6\r\nPENSA 5\r\nPENSA 7\r\nPENSA 8\r\nPENSA 13\r\nPENSA 14\r\nPENSA 136\r\n","assignee":{"name":"DEPOM"},"reporter":{"name":"HONNV"}}}


https://jira-dev01.onprvp.fgov.be/rest/api/2/issue

 

So basically, my json data is good + the URL is also good.

You've to know that I'm connected to RestClient with my own credentials (DEVAF) but here I'm trying to create an issue with assignee PATTA.

It ends with the issue created for DEVAF. Same for comments … even if the Rest call is correctly set.

 

The really weird stuff is that if I'm using «Advanced REST Client" plugin Chrome, doing exactly the same, it creates the issue correctly with Assignee PATTA.

I'm also connected with my DEVAF user … so it doesn't make any sense to me …

 

2) How to download attachments

I checked and tested plenty of examples on the Internet, I succeed to get the https://…/secure/<issue_id>/file.txt , but I'm just unable to download the file using REST API on my Ruby script.

It's unfortunate, as if I just put that URL on my browser, it works well …

 

Thanks for any help :)

 

Regards;

1 answer

0 votes
Florent Delvaille
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 4, 2018

You can forget about 1) , as:

- It's not possible to set a specific author while creating a comment, it'll always be the connected user unfortunately. Concerning the assignee, it was good until I changed the status (with transition) of the issue … so I now force the assignee at the end, and all is good.

 

So only point 2) to check :)

 

Thx

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events