Projects default settings through REST API

Hi,
I am a beginner…how can i set the default settings for a group of projects through the REST API (Code)?
Ex: set merge request approval rule and etc.
Shall i do it with Python or Bash script and how? Can you please show me an example of a script?

Many thanks in advance.

Hi @kab-2

Suggest reading the Gitlab API docs:

that explains the API features for merge requests. Whether you do it in Python/Bash, then you can use GET/PUT methods. Below for example will list all project info, so a GET request with bash:

 curl --header "PRIVATE-TOKEN: your-access-token-here" https://yourgitlab.domain.com/api/v4/projects/

you can apply the above URL to the merge requests documentation and then write your own scripts to do what you need it to do.

Hi @iwalker

Thanks for the info. Where should I push and run my code? in a randomly Gitlab project?

I wouldn’t call it random. First you need to create yourself a project with an appropriate name for whatever it is you are doing, and then you can push your code to this.

Your scripts don’t need to be in the project unless you wish to have other people work on them, or use them. But that is for you to decide.

Thanks a lot @iwalker you really help me…

Hi @iwalker
here me again. I have prepare some project settings and I have applied on a project that i have created before and it has worked but whenever i apply the same settings on a project that i didnt create it but i have enough permissions, it didnt work.
Actually in Terminal i didnt become any error but when i look in Gitlab UI, the changes didnt appear.

thanks.