post远程服务器返回错误: (415) 5C
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),求大侠指导。

7个回答

request.ContentType = 'application/json'.

可能是你URL请求错误

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

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

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

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

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

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐