• 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
     
    
  • 相关阅读:
    Markdown学习笔记
    Go 学习笔记(一)
    case中定义变量
    <转>MySql 与Oracle区别
    Java 时间转换问题总结
    线程之间共享
    并发编程快速入门
    redis主从复制
    jedis操作redis
    redis持久化方案
  • 原文地址:https://www.cnblogs.com/wybshyy/p/13783728.html
Copyright © 2020-2023  润新知