How to get updated records through REST API?

Ashok Kumar December 18, 2020

Hi Team, 

 

I have  REST URL as below using in ServiceNow doing "get" it is working fine, but I also want to get the records that are updated in last 1hr.

Please suggest how can I do that

https://jira.abc.com:443/rest/api/2/search?jql=project=REC&maxResults=100&key

Regards, 

K

1 answer

1 vote
Radek Dostál
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.
December 18, 2020

Hi Ashok,

 

Have you tried the 'updated' property?

project = REC and updated > -1h

 

Note - this will also show you issues where comments or work logs were added, it does not track just field or status values.

 

//R

Ashok Kumar December 21, 2020

Hi Radek, 

I tried like this as your mentioned above, still not able to retrieve records

getting an error invalid query 

https://jira.abc.com/rest/api/2/search?jql=project =REC and updated >-1h

 

Please let me know if I'm doing anything wrong here

Regards, 

Ashok

Radek Dostál
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.
December 21, 2020

Hi Ashok,

 

I'm guessing your query is not valid due to a problem something like a shell expansion (because '>' is a control character in shell) OR you are not authenticating in the request and so it cannot find the project.

 

Works fine for me without html char encryption if I paste the query in browser, so it makes me think that likely it's stemming from your client that you're sending the request from.

 

Do you have an option to wrap the URL parameter? Or you could try the POST format and provide the jql query as body.

 

Just to clarify what I mean is that if I use the raw jql, it will work OK in the browser, but if I were to send this with cURL, and the URL is not wrapped in single quotes '', then it will fail and try to redirect the output to a file "-1h". Something like this I think.

 

Regards,

Radek

Suggest an answer

Log in or Sign up to answer