I've the following code where I wanted to filter the results of actions where action_type contains purchase
https://graph.facebook.com/v14.0/ad_account_id?fields=insights{actions}&filtering=[{"field":"action_type","operator":"CONTAIN","value":"purchase"}]
But the result shows all the action types. Am I doing anything wrong?
The use of nested types is deliberate, the code works fine when not in nested queries like this
https://graph.facebook.com/v14.0/ad_account_id/insights?fields=actions&filtering=[{"field":"action_type","operator":"CONTAIN","value":"purchase"}]
While I didn't find exact solution of why this is not working a fix is found below using the params part of requests command like this
ps = {
'fields' : 'insights.fields(actions).filtering([{"field":"action_type","operator":"CONTAIN","value":"purchase"}])',
'access_token' : access_token
}
response = requests.get("https://graph.facebook.com/v14.0/id", params = ps)