所以我试图通过我在我的反应代码库中公开的这个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);
});