I am using the Facebook Graph API to upload a list of users to a custom audience. In the documentation for this action, it says that I should be able to upload up to 10,000 users at a time. However, cURL prevents me from doing so with the format of my current command, and the documentation doesn't give any other options for formatting the request. Here is what I currently have:
curl -X $HTTP_REQUEST_TYPE \
-H "Content-Type: application/json" \
--data-urlencode payload='{"schema": ["EMAIL_SHA256"],"data": ['$EMAIL_JSON']}' \
-d "access_token=$API_KEY" \
https://graph.facebook.com/v11.0/$AUDIENCE_ID/users
I tried adding the payload and access_token as a json formatted file, but the API denied that post method. The $EMAIL_JSON is the 10,000 long list of hashed emails. Here is the link to the documentation I have been using: Facebook Documentation.
Error ./facebook_api.sh: line 91: /bin/curl: cannot execute [Argument list too long]
Any help would be amazing.
I have solved the issue by changing the content type and using a file named "tempJson" to store the data:
curl -X $HTTP_REQUEST_TYPE \
-H 'Content-Type: application/x-www-form-urlen-coded' \
--data-urlencode payload@tempJson \
-d "access_token=$API_KEY" \
https://graph.facebook.com/v11.0/$AUDIENCE_ID/users
As you can see, I used payload@tempJson to specify the parameter name, and the data contained within. I found this solution at this website that describes the cURL request and the options while using --data-urlencode
. The data in the file looks exactly the same as the data that I was using in my question.