post远程服务器返回错误: (415)

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim url As String = "http://api.jsform.com/api/v1/entry/query"
        Dim request As HttpWebRequest = CType(HttpWebRequest.Create(url), HttpWebRequest)
        Dim encoding As New UTF8Encoding()
        request.Method = "POST"
        request.ContentType = "application/x-www-form-urlencoded"
        request.Credentials = CredentialCache.DefaultCredentials

        Dim ddd As String = "{" & Chr(34) & "form_id" & Chr(34) & ":" & Chr(34) & "5a6586b6e7aea961dac4a41d" & Chr(34) & "}"

      es(usernamepassword)))
        Dim code As String = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(String.Format("{0}:{1}", "5a44aa7fe7aea932ad6b5d56", "DwTTsvTQJGCCZiqwGQVj149YbJ8BHz1D")))
        request.Headers.Add("Authorization", "Basic " + code)

        Dim bys As Byte() = encoding.GetBytes(ddd)
        request.ContentLength = bys.Length
        Dim newStream As Stream = request.GetRequestStream()
        newStream.Write(bys, 0, bys.Length)
        newStream.Close()
        Dim sr As StreamReader = New StreamReader(request.GetResponse().GetResponseStream)

        TextBox3.Text = sr.ReadToEnd
    End Sub

远程服务器返回错误: (415),求大侠指导。

HTTP请求415错误 – 不支持的媒体类型(Unsupported media type)

是不是没有把code设置成 json 格式导致的

服务器能否接受你的表格类型数据

对,是不支持的数据类型,我今天也出现了这个问题,我是xml 转 java对象的时候报错了

在你的header上加上content-type:text/json
如果还不行,要看你的服务器怎么约定的。说了很多次了,要把文档贴出来。

抓个包看看请求头格式 保持一致就行了

request.ContentType = 'application/json'.

可能是你URL请求错误