GitLab api v4 curl actions


Im trying to POST files to a repo, but im strugeling with the actions array used in combination with “commits”
I’m using bash in combination with curl. First I received a message that “actions” was missing, so I tried “actions&action” which seems to be oke, but unfortunately no file is being updated, removed or created. Anyone?

I`m could use EOF JSON… which is working fine, but I prefer to commit files while using --data-urlencode.

curl -X POST -H “PRIVATE-TOKEN: {GITLAB_API_TOKEN}" \ --data-urlencode "actions&action={ACTION}”
–data-urlencode “author_name=test”
–data-urlencode “
–data-urlencode “file_path={DESTFILE}.yaml" \ --data-urlencode "branch={GIT_BRANCH}”
–data-urlencode “content=cat ${SRCFILE}
–data-urlencode "commit_message=0 - File {ACTION}: {DESTFILE}.yaml" \ {GITLAB_API_URL}/projects/${GIT_DESTPATH}/repository/commits

Also using {GITLAB_API_URL}/projects/{GIT_DESTPATH}/repository/files instead of commits seems to make a difference. I can use post/delete/put on files with API V3, but with API V4 I receive an error “404”. however, when I use
{GITLAB_API_URL}/projects/{GIT_DESTPATH}/repository/files/filname on API V4, the file is being created, but it uses filename instead of the filename used in file_path.

When defining file_path=filename (instead of a var) I still receive a 404 error but it’s working on API V3.
Using: GitLab Enterprise Edition 9.1.2-ee 6488043

Ofcourse when using API V3 I also use branch_name instead of branch.


did you manage to make this work?