各位大师,我是一菜鸟,在做一个api接口请求的时候,报签名错误,怎么回事?
{"success":false,"errorCode":"Base Param error","subErrorCode":"ErrorSign","errorDesc":"基本参数错误","subErrorDesc":"签名错误","requestMethod":null}
api接口提供的说明如下:
http://gop.guanyierp.com/interface/gy.erp.introd.htm
我的代码:
Dim jo As New JObject
jo("appkey") = "APPKEy"
jo("sessionkey") = "会话密钥"
jo("method") = "gy.erp.trade.get"
jo("page_no")="1"
jo("page_size")="10"
jo("start_date") = "2017-08-16 00:00:00"
jo("end_date") = "2017-08-16 24:00:00"
jo("date_type") =2
'jo("order_state") = 2
'jo("shop_code") = 2
Dim postjsonstring As String = jo.ToString
Dim secret As String = "安全密钥"
Dim sign As String = secret & postjsonstring & secret
sign = MD5Encrypt(sign)
jo("sign") = sign.ToUpper
postjsonstring= jo.ToString
'定义接口url
Dim url As String = String.Format("http://v2.api.guanyierp.com/rest/erp_open/")
'Json序列化到内存流
Using ms As New System.IO.MemoryStream()
Dim bytes = ConvertHelper.EncodingToBytes(postjsonstring , System.Text.Encoding.UTF8)
ms.Write(bytes, 0, bytes.Length)
ms.Seek(0, System.IO.SeekOrigin.Begin)
Dim jsonString = Functions.Execute("HttpPost",url, ms)
Dim mresult = ConvertHelper.FromJson(Of MmsgResult)(jsonString)
e.Form.Controls("TextBox1").Text = jsonString
问题出在哪里呢?