原文: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. MySQL事务未提交导致整个表锁死

    问题及说明: 当一个SQL事务执行完了,但未COMMIT,后面的SQL想要执行就是被锁,超时结束:报错信息如下: mysql> ERROR 1205 (HY000): Lock wait tim ...

  2. HUSKY CLOCK1.0上线啦!

    有人需要HUSKY CLOCK1.0下载资源的请联系1335415335@qq.com! 感谢支持,您的认可是我们前进的动力!

  3. NodeJS添加Jquery依赖

    NodeJS使用时有时候需要JQuery依赖. 新版正确的依赖方式 var jsdom = require('jsdom'); const {JSDOM} = jsdom; const {docume ...

  4. Regex 常见语法

    常用元字符 . 匹配除换行符以外的任意字符. \w 匹配字母或数字或下划线或汉字.\W 匹配任意不是字母,数字,下划线,汉字的字符. \s 匹配任意的空白符.\S 匹配任意不是空白符的字符.等价于 [ ...

  5. mysql删除重复数据(通过多个字段分组,删除某一字段为空的数据)

    DELETE FROM t_questions WHERE Id in ( SELECT Id FROM ( SELECT Id FROM `t_questions` WHERE (Name,Ques ...

  6. C++中的Point类与vector类的简单处理

    首先设计Vector与Point的表示方法,再依次完善两个类中的构造函数,复制构造函数等. 向量由两个点表示,当进行运算的时候,转化起点坐标为(0,0): 第14行:由于Vector需要用到Point ...

  7. 2019-08-26 linux

    1.question:什么是linux? answer:Linux由林纳斯·托瓦兹开发的一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和Unix的多用户.多任务.支持多线程和多CPU ...

  8. 微信小程序开发--flex详细解读

    一.结构:flex布局 是由一个大的容器加上多个子元素组成. <view class="container"> <view </view> <v ...

  9. 个人项目 python实现

    一.  github地址:https://github.com/zjh1234562/WC 二 . PSP表格 PSP2.1 Personal Software Process Stages 预估耗时 ...

  10. swagger 生成 api 文档 html

    https://cloud.tencent.com/developer/article/1332445 使用Swagger2Markup实现导出API文档 飞狗发表于专注于主流技术和业务订阅 2.4K ...