Commit file through gitlab API

Goal description:

Using our company Self managed gitlab, I have a script that need a data as input from a YAML file.
I would like to commit that data file through API which should trigger the pipeline to run the script.

I can trigger the pipeline and run the script with an already existing data.yaml file and things go well using something like that:

curl -X POST \
     -F token=XXXX \
     -F ref=dev \
     https://our_gitlab/api/v4/projects/YYYY/trigger/pipeline -o result.json

Now I am trying to attach a file to the trigger using two methods without success:


PAYLOAD=$(cat << 'JSON'
  "branch": "dev",
  "commit_message": "update data file API",
  "actions": [
      "action": "update",
      "file_path": "data.yml",
curl --request POST --header "PRIVATE-TOKEN: XXXX" --header "Content-Type: application/json" --data "$PAYLOAD" https://our_gitlab/api/v4/projects/YYYY/repository/commits


Nothing happen, no cli output nor pipeline trigger.


curl --request POST \
--form "branch=dev" \
--form "commit_message=test_push_file_from_api" \
--form "start_branch=dev" \
--form "actions[][action]=update" \
--form "actions[][file_path]=data.yml" \
--form "actions[][content]=data.yml" \
--header "PRIVATE-TOKEN: XXXX" \


{“message”:“401 Unauthorized”}

The token XXXX and the id in the API path YYYY are the same as the ones used to successfully trigger the pipeline without passing data

Used documentations:

Any hint?

Thanks in advance