API: Filter by Name Fails on Spaces

When using the Ghost Admin API to filter a list (posts, labels, tags etc) using the name filter (on the query parameters), it appears to fail when a space (either using a + or %20) is included.

For example: &name:Test Test

The response includes:
“message”: “Request not understood error, cannot list labels.”
“context”: “Error parsing filter”
“type”: “BadRequestError”

Is this a bug, or is this by design?

Can you share the exact query you’re making? name:Test Test doesn’t give enough context - e.g. if you’re trying to do this as part of the URL, it should be name="Test Test"

The query (and endpoint) is:
/ghost/api/v3/admin/labels?filter=name:"Test Test"

I’ve also tried without speech marks (just incase!)

I appear to be having the same BadRequestError when I include speech marks. So if I have a single word title and I add a speech marks around that one word, I get the same error as in the opening post.

This seems to be the case for the name field on labels and the title field on posts
/ghost/api/v3/admin/posts?filter=title:"Test Test".

I may well be getting something very simple very wrong!

Does it work if you use single quotes? filter=name:'Test Test'?

Ah! Yes it does!
And I’ve just found the place in the docs which says “Use single-quotes for these.”


1 Like