I'm trying to set user's avatar in bitbucket using bitbucket API - https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html#idm8283193008. Curl example from docs works for me, but I have no idea how to get my python requests working with given endpoint. The response is always 415, which means "wrong content type". Besides that, I believe, everything works fine, looks like the only problem is json parameter in requests.post method. My question is what should I write in json={'avatar': } to make it equal to @image.png in curl.
Asked
Active
Viewed 515 times
-1
-
2use http://curl.trillworks.com to convert `curl` to `python` – furas Feb 18 '20 at 17:59
-
Can you include more details, wrt. what the query looks like with curl and what your current Python code looks like, so someone can try to answer without following the link to the Atlassian docs? (Links are fine for expanding on a question, but we require a question to be answerable, and an answer to be understandable enough for other readers to learn from it, even if all links break). – Charles Duffy Feb 18 '20 at 17:59
-
@furas thank you so much, it worked for me. Very helpful website. – zavullon Feb 18 '20 at 18:05
1 Answers
0
@furas answered my question. curl.trillworks.com is a great website to convert curl to python. In my case I shouldn't have used json={}, instead I should've used file={filename, file_binary}

zavullon
- 43
- 1
- 6
-
BTW: tools for testing API [postman](https://www.postman.com/) and [insomnia](https://insomnia.rest/) have also function to generate `curl` command or code in Python (and other languages) – furas Feb 18 '20 at 19:12