I am trying to make POST request to GitLab and make file with my Python code. Url is fine I tested it in Postman and request worked fine and made file in repo.
But when i tried to use Python it didn't work.
Python code:
req = requests.post("https://gitlab.com/api/v4/projects/38163703/repository/files/python_code_test",
data={"start_branch": "main",
"branch": "main",
"content": "test python",
"commit_message": "python test"},
headers = {"PRIVATE_TOKEN": "<token>"})
print(req.status_code, req.reason)
Error:
403 Forbidden
CodePudding user response:
It's supposed to be PRIVATE-TOKEN
and not PRIVATE_TOKEN
in data.