According to official documentation curl request is
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "[email protected]" https://gitlab.example.com/api/v3/projects/5/uploads
I change it to python and get
import requests
headers = {
'PRIVATE-TOKEN': 'my_token'
}
form = {
'file': '@gaa.pdf'
}
print(requests.post('https://gitlab.com/api/v3/projects/4067343/uploads', headers=headers, form=form))
And I have response like
Traceback (most recent call last):
File "/home/k/pro/rat/try.py", line 19, in <module>
print(requests.post('https://gitlab.com/api/v3/projects/4067343/uploads', headers=headers, form=form))
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'form'
What should I do to have response with link instead of mistake?
wgetcommand truncated or is it your real token ?requests.postdoes not supportformparameter. See this question how to convertcurl's--formto Python's requests.