我正在尝试将以下cURL命令转换为将GitHub中的.diff内容传递给VB:
curl -H 'Authorization: token myGitHubToken' -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/[USR]/[REPO]/commits/[COMMITID]
cURL工作正常。我在VB中使用HttpWebRequest
的代码是
Dim url As New Uri("https://api.github.com/repos/[USR]/[REPO]/commits/[COMMITID]")
Dim myReq As HttpWebRequest = HttpWebRequest.Create(url)
SetAllowUnsafeHeaderParsing20()
myReq.Headers.Add("Authorization: token myGitHubToken")
myReq.Accept("application/vnd.github.v3.diff")
myReq.KeepAlive = False
Dim response As HttpWebResponse = CType(myReq.GetResponse(), HttpWebResponse)
但是在GetResponse
中,会向我发送WebException
:
“远程服务器返回错误:(403)禁止”
我的翻译好吗?有什么不对吗?