GITLAB API 在存储库中创建新文件

问题描述

所以我试图通过我在 React 代码库中公开的这个 api 在我的 git repo 中创建一个文件,但我收到 403 错误?让我知道我错在哪里。

var bodyData = {
      token: "**********",ref: "main",branch: "demo",commit_message: "create a new file",content: "some content"
    };
    fetch("https://gitlab.com/api/v4/projects/27622003/repository/files/myfile1%2Etxt",{
      method: "POST",headers: { "Content-Type": "application/json" },body: JSON.stringify(bodyData),})
      .then((response) => response.json())
      .then((data) => {
        console.log("response:",data);
      })
      .catch((error) => {
        console.error("Error:",error);
      });

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)