Unable to setup remote mirror via API


I’m trying to set up a project remote mirror via API using the following command:

curl -k --request POST --data “url=https://$GITUSER:$GITPASSWORD@git-codecommit.eu-west-1.amazonaws.com/v1/repos/$name&enabled=true” --header “PRIVATE-TOKEN: $TOKEN” “https://gitlab/api/v4/projects/$id/remote_mirrors

The command above creates the mirror for the project, but when I try to start the mirroring (update now), it fails with the following error:
13:get remote references: create git ls-remote: exit status 128, stderr: “fatal: unable to access ‘https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/my_project/’: The requested URL returned error: 403\n”.
If I create the mirror using the GUI with the exact same parameters, it works.