Home > Software design >  Facebook API 'Invalid rule JSON format' When Creating Custom Web Audience
Facebook API 'Invalid rule JSON format' When Creating Custom Web Audience

Time:12-19

I am using Graph API 12.0 to create a custom web audience and getting "Invalid rule JSON format" error. I believe I am using the exact format specified here

Below is my request:

{
  "name": "test",
    "rule": {
    "inclusions": {
      "operator": "or",
      "rules": [
        {
          "event_sources": [
            {
              "type": "pixel",
              "id": PIXEL_ID
            }
          ],
          "retention_seconds": 600
        }
      ]
    }
  },
  "retention_days": "1",
  "prefill": "1"
}

CodePudding user response:

It turns out "filter" was a required field even though it is stated optional in the documents. I think this is a bug within Facebook API. What if I don't need any filters?

Below request works successfully:

{
  "name": "test",
    "rule": {
    "inclusions": {
      "operator": "or",
      "rules": [
        {
          "event_sources": [
            {
              "type": "pixel",
              "id": PIXEL_ID
            }
          ],
          "retention_seconds": 600,
          "filter": {
                    "operator": "and",
                    "filters": [{
                        "field": "url",
                        "operator": "regex_match",
                        "value": "."
                    }]
                }
        }
      ]
    }
  },
  "retention_days": "1",
  "prefill": "1"
}
  • Related