|
网站需要用POST方式提交一个UTF-8的JSON格式的数据。
但提交后返回:The request content not valid json format for specified content-type=application/json
想请教各位什么原因?第一次使用JSON。没有经验
以下是代码片段:
ContentType="application/json;charset=utf-8"
PostData="{""ImageBase64"":""" + StrCovert.Base64Encode(True, sFileName) + """}"
'StrCovert.Base64Encode 是对某个二进制文件sFileName进行Base64编码,这个测试过结果没有问题的。
Private Function CPost(URL As String, Action As String, TimeStamp As String, _
ContentType As String, PostData As String) As String
'Post数据
Dim XMLHttp As Object
Set XMLHttp = CreateObject("MSXML2.XMLHTTP")
XMLHttp.Open "POST", URL, False
XMLHttp.setRequestHeader "Content-Type", ContentType ‘"application/json;charset=utf-8"
XMLHttp.setRequestHeader "Host", GetHost(URL)
XMLHttp.setRequestHeader "X-TC-Action", Action
XMLHttp.setRequestHeader "X-TC-Timestamp", TimeStamp
XMLHttp.send PostData
CPost = XMLHttp.ResponseText
End Function
|
|