0

I try to add users to custom audiences with this code:

{

    import requests
    import json

    payload = {'data': ['33f6fc8e08b0804555feeed0e0e81251bc408c7db58c7a030a8252731668afd0'],
               'schema': 'EMAIL_SHA256'}
    params = {'access_token': 'ACCESSTOKEN'}
    response = requests.post('https://graph.facebook.com/audience_id/users', 
                             params=params, data=json.dumps(payload))
    response.json()

}

The response is:

{

    {u'error': {u'code': 1,
     u'message': u'An unknown error has occurred.',
     u'type': u'OAuthException'}}

}

It's interesting that even the original example with curl returns the same result however the access token is valid and I can get data about audiences or create a new one with Python code.

Why I get this error?

Malwinder Singh
  • 6,644
  • 14
  • 65
  • 103

1 Answers1

0

The solution for my problem:

{
    import requests
    import json

    payload = {'data': ['33f6fc8e08b0804555feeed0e0e81251bc408c7db58c7a030a8252731668afd0'],
               'schema': 'EMAIL_SHA256'}
    params = {'access_token': 'ACCESSTOKEN', 'payload': json.dumps(payload)}
    response = requests.post('https://graph.facebook.com/audience_id/users', 
                             params=params)
    response.json()
}
Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71