vb.net 接口POST方式传参数提交返回值

Try
                                    Dim WebClientObj As New System.Net.WebClient()
                                    Dim PostVars As New System.Collections.Specialized.NameValueCollection()
                                    'URL
                                    Dim url1 As String = "http://ip地址/sso/rest/user/create.json"
                                    '参数一:requestTime 时间差
                                    Dim requestTime As String = CLng((DateTime.UtcNow - Jan1st1970).TotalMilliseconds).ToString()
                                    '参数二:content。要用双引号拼接 <span style="font-family: Arial, Helvetica, sans-serif;">Chr(34) 双引号的意思</span>
                                    Dim content1 As String = "{'fullName': '名字','name': '名字','sn': '名字','givenName': '名字','displayName': '名字','mail': 'sdfsadgsd@fubon.com.cn','unicodePwd': '111'}"
                                    '参数三:sign
                                    Dim sign As String = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(content2, "MD5")
                                    ''参数四:Authorization
                                    Dim base1 As String = "Basic WldsdzpVMkZzZEdWa1gxK0NzQzZXWHNZRHN0eEllcndMN1lkTExoWC83ZTZ6dGt3PQ=="
                                    PostVars.Add("requestTime", requestTime)
                                    PostVars.Add("content", content1)
                                    PostVars.Add("sign", sign)
                                    Try
                                        '设置Headers
                                        WebClientObj.Headers.Add("Authorization", base1)
                                        '请求URL和参数
                                        Dim byRemoteInfo As Byte() = WebClientObj.UploadValues(url1, "POST", PostVars)
                                        '获取返回信息
                                        Dim sRemoteInfo As String = System.Text.Encoding.[Default].GetString(byRemoteInfo)
                                        '这是获取返回信息
                                        Dim str5 As String = sRemoteInfo
                                    Catch
                                    End Try
                                Catch ex As Exception
                                End Try
 

posted @ 2016-10-26 11:12  离。  阅读(389)  评论(0编辑  收藏  举报