I'm using Python requests and trying to upload an image to Facebook Ads API server.
I can put the image in the body using data
requests.post(endpoint, data={'pic.jpg': open('pic.jpg', 'rb')})
and then when I print the body of the request, it looks like pic.jpg=%FF%D8%FF%E0%00%10JFIF...
with a looong string of those %_ things (I guess those are the bytes?)
I can also put the image in the body using files
requests.post(endpoint, files={'pic.jpg': open('pic.jpg', 'rb')})
and then when I print the body of the request, it looks like
--7bfdd12d05f549f3953f32165da5900c
Content-Disposition: form-data; name="pic.jpg"; filename="pic.jpg"
????JFIFHH??C
!1AQ"q2??????#BRW?$3b????7Cr????...
with a ton more ?'s and weird symbols.
Which is correct, if either, for doing file upload? For the top one I get back []
from the Facebook API and for the second one I get back null
.