首页 > 其他分享 >Get请求

Get请求

时间:2023-06-01 12:01:24浏览次数:34  
标签:请求 GET Get request token HttpWebRequest string

 GET不支持GetRequestStream(),所以不能写进去:

             string baseUrl = "http://";

             string token = "";
      
                try
                {

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(baseUrl);
      
                //设置 GET 请求方式
                request.Method = "GET";
                request.ContentType = "application/x-www-form-urlencoded";
                //设置请求头部信息
                request.Headers.Add("token", token);
         
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                 {
                    string result = sr.ReadToEnd();
                    Console.WriteLine(result);
                   
                 }
               }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            

 

标签:请求,GET,Get,request,token,HttpWebRequest,string
From: https://www.cnblogs.com/shiningleo007/p/17448544.html

相关文章

  • 对接第三方接口教程(发送Http请求及返回参数处理)
    1.首先Http工具类建议使用 packagecn.hutool.http;//这个包下面的HttpUtil.post(StringurlString,Stringbody)这个方法会省去很多事情,不用去设置header的一些基本东西,get就不说了,get也能用post请求,把参数拼url后边就行了2.要看第三方接口的鉴权是如何做的,如果是t......
  • python目录扫描工具——dirsearch使用,可以使用御剑的字典 支持慢速扫描,一般使用-s 60
    使用御剑的字典:pythondirsearch.py-uxxx.com-e*-w/media/dir_dict/ASP.txt,/media/dir_dict/ASPX.txt,/media/dir_dict/DIR.txt,/media/dir_dict/JSP.txt,/media/dir_dict/MDB.txt,/media/dir_dict/PHP.txt 非常好用!!!如下是御剑的字典文件。 进入dirsearch目录,进行扫描在这......
  • Arc get_mut
    ///Returnsamutablereferenceintothegiven`Arc`,ifthereare///noother`Arc`or[`Weak`]pointerstothesameallocation.//////Returns[`None`]otherwise,becauseitisnotsafeto///mutateasharedvalue.//////See......
  • MyBatis+Sharding-JDBC实体类LocalDateTime类型字段查询报SQLFeatureNotSupportedExce
    问题最近协助渠道组开发新需求,封装实现了一个公共模块供不同渠道项目使用。以前各个渠道项目有很多相似的菜单和功能,各自项目里自己的代码实现,本公共模块对新需求的功能点进行抽象,减少重复代码,提高模块复用性和可维护性。目前有2个渠道项目接入了该公共模块,自测时发现其中1个运......
  • uniapp onShareAppMessage里面请求后调分享(微信小程序)
    onShareAppMessage(){constpromise=newPromise(resolve=>{request({api:'请求名',method:'POST',data:{"data":{}}}).then(res=>{resolve({......
  • HTTP请求头的含义
    http请求中常用的请求头的含义:Accept:告诉服务器,客户端支持的数据类型。Accept-Charset:告诉服务器,客户端采用的编码。Accept-Encoding:告诉服务器,客户机支持的数据压缩格式。Accept-Language:告诉服务器,客户机的语言环境。Host:客户机通过这个头告诉服务器,想访问的主机名。If-Modified......
  • 2305.19270Learning without Forgetting for Vision-Language Models
    https://arxiv.org/pdf/2305.19270.pdf2305.19270.pd  AbstractClass-IncrementalLearning(CIL)orcontinuallearningisadesiredcapabilityintherealworld,whichrequiresalearningsystemtoadapttonewtaskswithoutforgettingformerones.Whiletradi......
  • Postman请求Azure的OpenAI
    界面是: AZURE_OPENAI_ENDPOINT/openai/deployments/deployment_name/chat/completions?api-version=2023-05-15注意Body下的raw选json格式 {"messages":[{"role":"system","content":"......
  • 果然python是直接可以使用requests去请求https站点的,意味着一般的扫描工具可以直接扫
    #coding:utf-8importrequests#请求地址#url="https://www.qlchat.com"url="https://www.baidu.com"headers={'user-agent':'Mozilla/5.0(WindowsNT10.0;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chro......
  • QA|selenium打开浏览器后没有执行后面的代码(get请求)|UI自动化测试
    Q:selenium打开浏览器后没有执行后面的代码(get请求)代码如图: 原因:webdriver_path应该给的是chromedriver.exe的路径,而不是chrome.exe的路径,写错了,正确的如下: 查阅参考:Selenium打开浏览器,但拒绝执行下一行代码-我爱学习网(5axxw.com)......