I am working on a WordPress website (but I think that the problem is not strictly related to WordPress but to some string encoding problem).
Basically I have two post in a specific post type named "Notary districts". This post type have a custom field named wpcf-idnotary-district containing a string value representing the ID of an object.
Ok then I have two different POST having different format for the value of this wpcf-idnotary-district field.
I have the following situation:
POST 1: the value of wpcf-idnotary-district field is 123456 POST 2: the value of wpcf-idnotary-district field is CG7drXn9fvA%253D
Then I have an WordPress API retrieving post from this post type by this wpcf-idnotary-district ID value.
Getting the previous POST 1 from my post type using the first value it is not a problem, infact calling my API passing this ID paramether, something like this:
https://www.MYPORTAL.it/wp-json/filter/notary-district?wpcf-idnotary-district=123456
I am obtaining the expected response:
[
{
"post_type": "notary-district",
"ID": 39244,
"wpcf-idnotary-district": "123456",
"post_title": "DISTRICT NAME TEST"
}
]
the problem happen getting the previous POST 2 using this ID, infact calling:
https://www.MYPORTAL.it/wp-json/filter/notary-district?wpcf-idnotary-district=CG7drXn9fvA253D
in this case the JSON response is an empty array:
[]
But, as you can see here it exist a post with this wpcf-idnotary-district field having CG7drXn9fvA%253D as value:
Trying to get this post calling my API give me this issue (an empty list, it doesn't find the post) both calling my API via Postman and by a Java batch application that I am developing.
I suppose that the problem is the % character into the CG7drXn9fvA%253D value, infact if I try to replace this post ID with this CG7drXn9fvA253D value (the previous one without the % character), then trying to search to this new value it works fine. So the problem is this % character.
I suspect that it is converting it in some way. Maybe I can try to pass the converted value as my API parameter but I have no idea about what I can try.
Some idea? How can I try to solve this problem?