Closed kerberjg closed 2 years ago
Hi there,
I spent some time looking into this and I think I found a solution. The reason Ghost doesn't like the +
is because the query language it uses - NQL - sees +
as a special character for filtering by something having both (ie looking for posts with both of the tags specified would use tag1+tag2
). So to get around this, simply wrap the email filter in quotes like so:
/ghost/api/canary/admin/members/?filter=email%3A'james.kerber%2Btest%40localhost'
Which, when decoded, the filter parameter becomes:
email:'james.kerber+test@localhost'
Or, in JS:
await ghost.api.members.browse({filter: `email:'${email}'`}});
Hey @kerberjg - the comment from @velocity23 above is correct in that the +
is a special character in NQL, and you'll need to wrap the email in quotes.
Issue Summary
When fetching Members through the Admin API (as suggested here: https://forum.ghost.org/t/query-member-by-email-with-admin-api/21941), and the email contains the '+' symbol (which is a standard subaddress marker), the API responds with an error:
This is a huge problem, as it means that certain users will experience usage issues due to their email address just having that character.
To Reproduce
GhostAdminAPI
with the correct URL and tokenawait ghost.api.members.browse({filter: 'email:'+email}});
with the email variable containing an address likehello+test@localhost
Technical details: