metadataKey and metadataValue formatting


I am struggling with proper formatting of metadataKey and metadataValue when using GET/members.

Could you please help me with what to put to metadataKey and metadataValue if I need to search for a member with “number”: “77”?

Our json in Metadata is formatted as following:

“locker”: [
“order”: “”,
“isPaid”: 1,
“number”: “77”,
“packageItemID”: 56058


Hey @janwithbeard!

Unfortunately, metadataKey and metadataValue only support simple queries at the root of the metadata object. So if you had metadata set to {locker: "77"} you could fetch that member with

GET /members?metadataKey=locker&metadataValue=77

But we don’t support checking nested properties or finding items in arrays at the moment. (Nerd details: Your example would require to check if the result of JSON path $.locker[*].number contained any result with the value 77.)

The only remedy I can think of at the moment is to add a property hasLocker: true to every member with a locker and then querying

GET /members?metadataKey=hasLocker&metadataValue=true

to limit the number of results to those who have a locker and then looping over them to find the one with the right locker.
(Or you can skip adding hasLocker and always loop over all members. That’s just much less efficient if only a few have lockers.)

I’m sorry I can’t offer you a better solution at the moment. But I’ll keep this use case in mind for future improvements.

Hey @raphael, thank you for the thorough answer – good to know for our future implementations.

1 Like