Open link in a new tab

Content

Expand project menu

API - Get tasks filtered by version

Hi.
I am trying to use API to get all work packages with no version set.
As result I'm getting error:
{
"_type": "Error", "errorIdentifier": "urn:openproject-org:api:v3:errors:InternalServerError",
"message": "An internal error has occured. undefined method `keys' for ["n", "version"]:Array"
}

According to API documentation I tried to gather filter from URL in browser with listed packages:
{"n":"version","o":"!*"}

Is there a way, how to get such filtered list using API?

Message actions

Simple example of extracting IDs of packages with no version assigned.

for id in $(curl -s -u apikey:YOUR_KEY 'https://HOST/api/v3/work_packages?filters=%5B%7B%22version%22%3A%7B%22operator%22%3A%22%21%2A%22%2C%22values%22%3A%5B%5D%7D%7D%5D' | jq '._embedded  .elements | to_entries[] .value .id'); do 
	echo ID $id;
done