ABP 后台调用接口 获取返回的数据
原文: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 后台调用接口 获取返回的数据的更多相关文章
- ABP JS调用接口 获取返回的数据
var _userService = abp.services.app.user; console.log(abp.services.app.user); _userService.getUserBy ...
- ASP.NET WEB API微信支付通知接口,返回xml数据,微信服务器不识别问题
原文:ASP.NET WEB API微信支付通知接口,返回xml数据,微信服务器不识别问题 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/MrTra ...
- coco2dx jni 调用 java 相机返回 图片数据
新建 一个项目 名字:testJin 包名:com.TanSon.org python命令:python create_project.py -project testJin -package c ...
- 使用httpClient调用接口获取响应数据
转自:https://blog.csdn.net/shuaishuaidewo/article/details/81136088 import lombok.extern.slf4j.Slf4j; i ...
- 微信小程序前端调用后台方法并获取返回值
wxml代码 <wxs src="../../wxs/string.wxs" module="tools" /> <!-- 调用tools.i ...
- C# HttpWebRequest 后台调用接口上传大文件以及其他参数
直接上代码,包各位看客能用!!! 1.首先请求参数的封装 /// <summary> /// 上传文件 - 请求参数类 /// </summary> public class ...
- java调用shell获取返回值
转自:http://blog.csdn.net/tengdazhang770960436/article/details/12014839 1.shell文件return.sh echo 1 echo ...
- 请求接口获取到的数据其中出现null值,处理的时候导致了程序crash,解决方案如下:
第一种方法是使用分类给字典添加一个类方法,将字典中的null值全部替换为空字符串,代码如下: .h文件代码: @interface NSDictionary (DeleteNull) + (id)ch ...
- jQuery调用ajax获取json格式数据
<body> <div>点击按钮获取音乐列表</div> <input type="button" id="button&quo ...
随机推荐
- PHP for的1个问题
PHP for的1个问题 <pre><?php for ($k = 13; $k > 0; $k--) { echo 'wef'; }?></pre>ps: ...
- Key ssd_300_vgg/block3_box/L2Normalization/gamma not found in checkpoint的解决方案
在Tensorflow下使用SSD模型训练自己的数据集时,经过查找很多博客资料,已经成功训练出来了自己的模型,但就是在测试自己模型效果的时候,出现了如下错误. 2019-10-27 14:47:12. ...
- 前端学习:HTML的学习总结
html简介 1 html是什么:超文本标记语言 超文本:文字/图片/音频/视频 标签/标记:<body></body> 怎么做:使用标签来创建网页 2 HTML的用途:是用来 ...
- 关于NB-IoT,没有比这篇更通俗易懂的啦!
来源:内容来自「鲜枣课堂」,谢谢. 大家好,我是小枣君. 今天,我是来“吹NB”的.嗯,标题已经剧透了,这个NB,就是NB-IoT. 在过去的一年多,NB-IoT真的可以说是大红大紫.在通信圈里,除了 ...
- 浅析libuv源码-node事件轮询解析(2)
上一篇讲了轮询的边角料,这篇进入正题.(竟然真有人看我博客,上两个图给你们整理下思路) 这是轮询总流程图. 下图为本节内容简图. Poll for I/O The loop blocks for I/ ...
- SpringMVC重要注解 @ControllerAdvice
@ControllerAdvice,是Spring3.2提供的新注解,从名字上可以看出大体意思是控制器增强.让我们先看看@ControllerAdvice的实现: package org.spring ...
- .Net IOC框架入门之——Autofac
一.简介 Autofac是.NET领域最为流行的IOC框架之一,传说是速度最快的一个 目的 1.依赖注入的目的是为了解耦.2.不依赖于具体类,而依赖抽象类或者接口,这叫依赖倒置.3.控制反转即IoC ...
- PIE SDK打开自定义栅格数据
1. 数据介绍 信息提取和解译的过程中,经常会生成一部分中间临时栅格数据,这些数据在执行完对应操作后就失去了存在的价值,针对这种情况,PIE增加了内存栅格数据集,来协助用户完成对自定义栅格数据的读取和 ...
- ASP.NET Core MVC上传文件
使用模型绑定上传小文件 HTML代码: <form method="post" enctype="multipart/form-data" asp-con ...
- Java 之 Stack 集合
一.Stack:栈 概述 栈是一种先进后出(FILO)或后进先出(LIFO:Last in first out)的数据结构. Stack是Vector的子类,比Vector多了几个方法,它的后进先出的 ...