在Visual Basic中创建请求URL。相同的网址将在trello的测试屏幕中起作用
伙计们,所以编写一个小部件,通过Web API将新卡添加到Trello。我在他们的开发人员门户网站中玩过,并且可以使用相同的URL,但是在Visual Basic中运行时,等待响应时会引发404错误。任何帮助,将不胜感激。这是针对学校项目的,因此相对较新。非常感谢。
Imports System.IO
Imports System.Net
Imports Newtonsoft.Json.Linq
Imports System.Text
Public Class Form1
Private Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click
Dim cardName As String = name.Text.ToString
Dim cardtext As String = desc.Text.ToString
Dim cardUploadURL As String = "https://api.trello.com/1/cards?name=" + cardName + "&desc=" + cardtext + "&pos=top&idList=5b67fe11c8bc945a40b905fe&keepFromSource=all&key=c1b9497af5a50f3392ffe1331863ccab&token=63238f657944a4c276d2d136b8baba6ba0ac78906aa6bfcdb87f469789440feb"
MessageBox.Show(cardUploadURL)
dataGet(cardUploadURL)
MessageBox.Show("card Uploaded")
End Sub
Public Shared Function dataGet(URL As String)
Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
request = DirectCast(WebRequest.Create(URL), HttpWebRequest)
response = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())
Dim data As String
data = reader.ReadToEnd()
Return data
End Function
结束类 和错误消息:
System.Net.WebException 'The remote server returned an error: (404) Not Found.'
答案 0 :(得分:0)
在原始发布的代码中,URL参数中的几行编码为空格:
scale*seconds=value of dash/frag
这对于HttpWebRequest对象不是必需的-URL编码将自动处理。
这可能是404的原因-可能是对编码空间进行了双重编码(或者其他,使用诸如Fiddler之类的工具可能会告诉您出了什么问题)?哪个取决于所调用的api接口可能导致其返回404。