Google apps script urlfetch encoding URL

前端 未结 2 1424
情书的邮戳
情书的邮戳 2021-01-17 09:27

I would like to use urlfetch to populate a spreadsheet with page data but the URL that I am trying to use is coming back with an error as an invalid argument. I think the pr

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-17 10:17

    You personally probably don't need the answer, but I write for the ones that need. In order to make a successful API call (API v4) to GitLab you need to encode only the "variables". See below:

    var url = baseUrl + projectId + "/repository/files/" + encodeURIComponent(pathAndFileName) + "?branch=" + encodeURIComponent(branch) + "&author_email=" + encodeURIComponent(authorEmail) + "&author_name=" + encodeURIComponent(authorName) + "&content=" + encodeURIComponent(content) + "&commit_message=" + encodeURIComponent(commitMessage);
    

    Where pathAndFileName is a variable that was defined earlier.

提交回复
热议问题