使用LINE BOT API获取(400)内部服务器错误

时间:2016-06-09 03:15:20

标签: .net line internal-server-error

我正在对LINE SENDING MESSAGE BOT API进行简单测试,但总是得到400 https://developers.line.me/bot-api/getting-started-with-bot-api-trial#sending_messages

Dim j As String = "{"
    j += "to: ['" & from & "'],"
    j += "toChannel: " & fromChannel & ","
    j += "eventType:  '" & eventType & "',"
    j += "content: {"
    j += "contentType: 1,"
    j += "toType: 1,"
    j += "text:'hello!!'"
    j += "}"
    j += "}"
        Dim baseAddress = "https://trialbot-api.line.me/v1/events"

        Dim http = DirectCast(WebRequest.Create(New Uri(baseAddress)), HttpWebRequest)
        http.Accept = "application/json; charser=UTF-8"
        http.ContentType = "application/json; charser=UTF-8"
        http.Headers.Add("X-Line-ChannelID", "123456789")
        http.Headers.Add("X-Line-ChannelSecret", "xxxxxxxxx")
        http.Headers.Add("X-Line-Trusted-User-With-ACL", "xxxxxx")
        http.Method = "POST"


        Dim parsedContent As String = j
        Dim encoding As New ASCIIEncoding()
        Dim bytes As [Byte]() = encoding.GetBytes(parsedContent)

        Dim newStream As Stream = http.GetRequestStream()
        newStream.Write(bytes, 0, bytes.Length)
        newStream.Close()

        Dim response = http.GetResponse()

        Dim stream = response.GetResponseStream()
        Dim sr = New StreamReader(stream)
        Dim content = sr.ReadToEnd()

我不知道如何解决它。请帮助我,谢谢。

0 个答案:

没有答案