所以,我正在尝试制作一个能为我上传视频的程序,所以我不需要花太多时间,而且我想出了以下代码:
Imports System
Imports System.Net
Imports System.IO
Module Module1
Sub Main()
Dim bytearray As String = "code=4/5tC9qk5APvWf_05GJRG-Ws5Ph4B1xXMZd0gw4iZEB50&
client_id=349673303318-cp0upvjfcijukhnloppnpl5v57qkrr53.apps.googleusercontent.com&
client_secret=s7gStNsZWua50Hlpot2XfSga&
redirect_uri=https://localhost/oauth2callback&
grant_type=authorization_code"
Dim request As WebRequest = WebRequest.Create("https://accounts.google.com/o/oauth2/token")
request.Credentials = CredentialCache.DefaultCredentials
request.Method = "POST"
request.ContentLength = bytearray.Length
request.ContentType = "application/x-www-form-urlencoded"
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write((Text.Encoding.UTF8.GetBytes(bytearray)), 0, bytearray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
My.Computer.Clipboard.SetText(Convert.ToString(response.GetResponseStream))
response.Close()
End Sub
End Module
这是在Visual Basic中。
问题是,当我发送请求时,它会从服务器返回错误400(错误请求)。
答案 0 :(得分:0)
请检查其他错误详情,然后您可以参考YouTube - Errors来帮助您解决遇到的错误。
此外,此SO帖子中的评论Youtube Api : Error 400 Bad Request while uploading videos也可能有所帮助。