原文:https://www.cnblogs.com/i3yuan/p/10703500.html

insert 简单测试:

        public void test8()
{
string url = "http://localhost:21021/api/services/app/Role/Create"; var str2 = HttpPost3(url, System.IO.File.ReadAllText("2.txt"));
Console.WriteLine(str2);
Console.Read();
}
        public string HttpPost4(string url, string body)
{
Encoding encoding = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json-patch+json";
byte[] buffer = encoding.GetBytes(body);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, , buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
return reader.ReadToEnd();
}
}

update简单测试:

        public void test10()
{
string url = "http://localhost:21021/api/services/app/Menu/Update";
var str2 = HttpPost5(url, "{\"name\": \"1\",\"url\": \"1\",\"id\": \"1\"}");
Console.WriteLine(str2);
Console.Read();
}
        public string HttpPost5(string url, string body)
{
Encoding encoding = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "PUT";
request.ContentType = "application/json-patch+json";
byte[] buffer = encoding.GetBytes(body);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, , buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
return reader.ReadToEnd();
}
}

delete简单测试:

        public void test11()
{
string url = "http://localhost:21021/api/services/app/Menu/Delete?Id=12";
var str2 = Delete("", url);
Console.WriteLine(str2);
Console.Read();
}
        public string Delete(string data, string uri)
{
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(uri);
byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(data);
Request.Method = "DELETE";
Request.ContentLength = buf.Length;
Request.ContentType = "application/json";
Request.MaximumAutomaticRedirections = ;
Request.AllowAutoRedirect = true;
Stream stream = Request.GetRequestStream();
stream.Write(buf, , buf.Length);
stream.Close();
HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
StreamReader reader = new StreamReader(Response.GetResponseStream(), Encoding.UTF8);
string returnXml = reader.ReadToEnd();//利用StreamReader就可以从响应内容从头读到尾
reader.Close();
Response.Close();
return returnXml;
}

ABP 后台调用接口 获取返回的数据的更多相关文章

  1. ABP JS调用接口 获取返回的数据

    var _userService = abp.services.app.user; console.log(abp.services.app.user); _userService.getUserBy ...

  2. ASP.NET WEB API微信支付通知接口,返回xml数据,微信服务器不识别问题

    原文:ASP.NET WEB API微信支付通知接口,返回xml数据,微信服务器不识别问题 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/MrTra ...

  3. coco2dx jni 调用 java 相机返回 图片数据

    新建 一个项目 名字:testJin  包名:com.TanSon.org  python命令:python create_project.py -project testJin -package c ...

  4. 使用httpClient调用接口获取响应数据

    转自:https://blog.csdn.net/shuaishuaidewo/article/details/81136088 import lombok.extern.slf4j.Slf4j; i ...

  5. 微信小程序前端调用后台方法并获取返回值

    wxml代码 <wxs src="../../wxs/string.wxs" module="tools" /> <!-- 调用tools.i ...

  6. C# HttpWebRequest 后台调用接口上传大文件以及其他参数

    直接上代码,包各位看客能用!!! 1.首先请求参数的封装 /// <summary> /// 上传文件 - 请求参数类 /// </summary> public class ...

  7. java调用shell获取返回值

    转自:http://blog.csdn.net/tengdazhang770960436/article/details/12014839 1.shell文件return.sh echo 1 echo ...

  8. 请求接口获取到的数据其中出现null值,处理的时候导致了程序crash,解决方案如下:

    第一种方法是使用分类给字典添加一个类方法,将字典中的null值全部替换为空字符串,代码如下: .h文件代码: @interface NSDictionary (DeleteNull) + (id)ch ...

  9. jQuery调用ajax获取json格式数据

    <body> <div>点击按钮获取音乐列表</div> <input type="button" id="button&quo ...

随机推荐

  1. WPF DataGrid 自定义样式 MVVM 删除 查询

    看到很多小伙伴在找Dategrid样式 就分享一个 ,有不好的地方 请指出 代码部分都加了注释  需要的可以自己修改为自己需要的样式 源码已经上传 地址:  https://github.com/YC ...

  2. sqlyog -------- 安装

    SQLyog是RDBMS MySQL的GUI工具.在从Windows Vista到Windows 10的Windows平台上运行,使用Wine环境,还使其可以在Linux和各种Unix(包括macOS ...

  3. Installing Google Chrome in Linux(RedHat Enterprise Linux 7)

    # wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm # yum -y install r ...

  4. Mysql系列(十一)—— 性能分析慢查询日志

    转载自:http://www.cnblogs.com/kerrycode/p/5593204.html 慢查询日志概念 MySQL的慢查询日志是MySQL提供的一种日志记录,它用来记录在MySQL中响 ...

  5. spring boot 在eclipse里启动正常,但打包后启动不起来

    现象描述: spring boot 在eclipse里启动正常,但打包后启动不起来. 错误日志如下: D:\Project>java -jar MKKY_CMS.jar . ____ _ __ ...

  6. Blend 硬货 绑定

    原文:Blend 硬货 绑定 开始讲一点 硬技能 怎么用Blend实现绑定 效果 详细说一下绑定 1)default 2)OneTime 3) One Way 4)TwoWay 5) OneWayto ...

  7. 史上最全的音视频SDK包分享给大家

    史上最全的音视频SDK包分享给大家 概述一下SDK功能: 项目 详情视频通信  支持多种分辨率的视频通信语音通信  提供语音通信,可支持高清宽带语音动态创建房间  可以根据需要,随时创建房间H5 支持 ...

  8. ArrayList集合的

    import java.util.ArrayList; /* * 如果想向集合ArrayList中存储基本数据类型,必须使用基本数据类型的“包装类” * * 基本类型 包装类(引用类型,包装类型都位于 ...

  9. javascript中的12种循环遍历方法1

    1:for循环 let arr = [1,2,3]; for(let i =0;i<arr.length;i++){ console.log(i,arr[i]) } //for循环是js中最常用 ...

  10. 尝试在Mac/iOS上使用tcmalloc库

    概述        TCMalloc 是 Google 开发的内存分配器,在不少项目中都有使用,例如在 Golang 中就使用了类似的算法进行内存分配.它具有现代化内存分配器的基本特征:对抗内存碎片. ...