Mehedee
Mehedee

Reputation: 336

How to filter marketplace vehicles with Facebook API

I am doing /vehicles?limit=300&filter=[{"field":"vehicle_id", "value":"106892", "operator": "EQUAL"}] and then getting error (#100) For field 'vehicles': Param filter must be a valid WCA rule..

==== Query
  curl -i -X GET \
   "https://graph.facebook.com/v9.0/{catelog_id}/vehicles?limit=300&filter=%5B%7B%22field%22%3A%22vehicle_id%22%2C%20%22value%22%3A%22106892%22%2C%20%22operator%22%3A%20%22EQUAL%22%7D%5D&access_token=<access token sanitized>"

==== Parameters
- Query Parameters
  {
    "limit": "300",
    "filter": "[{\"field\":\"vehicle_id\", \"value\":\"106892\", \"operator\": \"EQUAL\"}]"
  }
- POST Parameters
  {}
==== Response
  {
    "error": {
      "message": "(#100) For field 'vehicles': Param filter must be a valid WCA rule.",
      "type": "OAuthException",
      "code": 100,
      "fbtrace_id": "xxx"
    }
  }

Facebook Ref: https://developers.facebook.com/docs/marketing-api/reference/product-catalog/vehicles/. I cannot find any clear guide how this filter should be.

Upvotes: 1

Views: 2979

Answers (1)

Matteo
Matteo

Reputation: 39430

The filter field should be a valid JSON-encoded WCA rule expression representing the filter to be applied for the edge. You could find reference for this definition here and here (Filter Rules, se also the Example Filter Rules section). In your example, should be something like:

/vehicles?filter={"vehicle_id":{"eq":"106892"}}

Upvotes: 1

Related Questions