How to detect non-existent issues using REST API query

I need to sync a mysql database with a subset of issues in JIRA.
Some issues are deleted or moved to another Project. Querying the JIRA Project results in error 400 for some issue IDs. This will be used for deleting these IDs from the mysql database, keeping the database in sync with JIRA.
However, when I query JIRA in batches of 1, 5, 10 or 20 issue IDs I get different results.
So eg. the batch of 5 IDs does not show all IDs that are missing. Batches of 1 however is not very efficient.

How can I get to know which IDs cannot be found in JIRA using batches of 20 or even bigger?

Hello @jgoor

When you said you “query JIRA in batches” you didn’t say how you were doing that multi-issue query.

What Jira Server REST API endpoint are you using and what example can you provide of your method?

You can search all issues in the project by JQL - it does batches by 100, and then check that IDs with your DB.

To do it more efficiently, you can:

  • Add a custom field to the chosen issues and narrow JQL by this custom field.
  • Add a issue property, index it by a Connect plugin and narrow JQL by this property.
  • Add a remote link with globalId and narrow JQL by this remote link globalId (this is a weird solution, but AFAIK only one without need of plugin or a custom field).