How to get all worklogs with a specific custom field value, with REST API?

Llewelyn Griffiths September 13, 2017

I've had a look through the REST API and I'm not sure if this is possible. Currently I want to get all the worklogs with a specific custom field value using the API. I understand I can do this with a search on my browser, however that only gets all the worklogs for a single project. I want to do this accross all projects.

Is this possible with a curl command, and how would I do it?

Thanks

2 answers

1 vote
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2017

Try a JQL query for that field to confirm it, before ruling it out. If you get the message The operator '=' is not supported then you may need to think of an altertive way of filtering.

Otherwise you could return worklogs for ALL issues and filter the returned results, but this isn't an ideal way of doing it and could potentially take a long time

Llewelyn Griffiths September 13, 2017

I just tried it now, yeah I'm getting that exact message. Ah well, I'll do it the other way instead.

Llewelyn Griffiths September 13, 2017

I guess I could use - text ~ "some_text", but that would probably be unreliable?

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2017

Interesting idea - I just tried customfield ~ "some_text" and it does return some results, but you may get more than you're expecting. It will also return an issue that has "some_text some_other_text" in the field i.e. the ~ matches all occurences, even where your search criteria isn't the entire field value

Llewelyn Griffiths September 13, 2017

I just tried it out now, and it works rather nicely actually!

One last thing, how would I put that JQL in a curl command?

Something along the lines of : "curl -u username:password http://my.domain/rest/api/2/search?customfield ~ some_text"?

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2017
http://my.domain/rest/api/2/search?fields=key,worklogs&jql=customfield_xxxx~"some_text"

This should hopefully work for you. Specifying the fields to return reduces the size of the returned data - add any other fields you require separated by a comma, or remove the fields= completely

0 votes
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2017

Hi Llewelyn

Before I actually tell you how to do it, I want to check that I understand the question.

You want to get the worklogs for all issues that have a specific value in a specific custom field. Is this correct?

What type of custom field is it? I ask because Text Fields (either single line or multi line) cannot be queried for a value i.e. you can't use mycustomfield = "some_text", via a JQL query. If it is  a date field you can use mycustomfield >= 2d.

Let me know about this and then we can see about further guidance

Llewelyn Griffiths September 13, 2017

Thank you for the quick response, yes you are correct.

It's a single line Text Field. So perhaps this isn't possible?

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2017

This reply is messed up - I'll do it again

Picture0004.jpg

Suggest an answer

Log in or Sign up to answer