I have a Strapi project, and when I try to get an entry with a specific value, it gives me all the results.
When I try to put this request :
curl -X GET "http://127.0.0.1:1337/api/people?filters[lastName][$eq]=Doe" \ -H "Authorization: Bearer <token>"
the CLI gives me this :
curl: (3) bad range in URL position 42:
http://127.0.0.1:1337/api/people?filters[lastName][]=Doe
^
So I execute this command (replace "[" and "]" by "%5B" and "%5D") :
curl -X GET "http://127.0.0.1:1337/api/people?filters%5BlastName%5D%5Beq%5D=Doe" \ -H "Authorization: Bearer <token>"
But it gives me all the entries.
{
"data": [
{
"id": 4,
"attributes": {
"lastName": "Doe",
"createdAt": "2024-05-15T20:50:42.148Z",
"updatedAt": "2024-05-15T20:50:42.148Z",
"publishedAt": "2024-05-15T20:50:42.142Z"
}
},
{
"id": 5,
"attributes": {
"lastName": "Smith",
"createdAt": "2024-05-15T21:07:30.250Z",
"updatedAt": "2024-05-15T21:07:32.543Z",
"publishedAt": "2024-05-15T21:07:32.541Z"
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 2
}
}
}
And this is the expecting result :
{
"data": [
{
"id": 4,
"attributes": {
"lastName": "Doe",
"createdAt": "2024-05-15T20:50:42.148Z",
"updatedAt": "2024-05-15T20:50:42.148Z",
"publishedAt": "2024-05-15T20:50:42.142Z"
}
},
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 1
}
}
}
I tried to search, but I didn't find many results with the same problem as mine.
Try like this
curl -X GET "http://127.0.0.1:1337/api/people?filters%5BlastName%5D%5B%24eq%5D=Doe" -H "Authorization: Bearer <token>"