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 ...
随机推荐
- Beta冲刺(9/7)——2019.5.31
作业描述 课程 软件工程1916|W(福州大学) 团队名称 修!咻咻! 作业要求 项目Beta冲刺(团队) 团队目标 切实可行的计算机协会维修预约平台 开发工具 Eclipse 团队信息 队员学号 队 ...
- vulnhub之SP:Harrison靶机
下载地址:‘https://www.vulnhub.com/entry/sp-harrison,302/’ 环境:靶机放在virtualbox上运行,网卡模式 攻击机:kali Linux运行在VMw ...
- nginx报错111: Connection refused
最近遇到了nginx疯狂抛错,access.log一天一共5W多条,但error.log中有大概9K多条,基本都是111: Connection refused,这到底是为什么呢? 从日志看起 我们还 ...
- springboot打war包汇总
概述 第一次用maven工具打war包,出现各种各样的问题,做个问题记录方便下次查看 maven 一开始用的maven是springboot默认的,在.m2下,要打包时才发现没有mvn指令.索性自己就 ...
- sitemap 文件的生成 sitemap文件和sitemapindex 索引文件的生成
<?php /*****连接数据库 start*******/ $dbhost = "localhost"; $username = "root"; $u ...
- window.postMessage()实现跨域消息传递
window.postMessage() 方法可以安全地实现跨源通信.通常,对于两个不同页面的脚本,只有当执行它们的页面位于具有相同的协议(通常为https), 端口号(443为https的默认值), ...
- python--进程初识详解
进程:通俗理解一个运行的程序或者软件,进程是操作系统资源分配的基本单位 1.1.导入进程模块 import multiprocessing 1.2.Process进程类的语法结构如下: Process ...
- Spring扩展点之BeanPostProcessor
前言 BeanPostProcessor接口是Spring中一个非常重要的接口,它的接口定义如下 public interface BeanPostProcessor { Object postPro ...
- Mybatis映射文件标签(关于sql)
Mybatis映射文件 1.接口的全限定名和映射文件的namespace一致 <mapper namespace="com.offcn.dao.UserDao"> 2. ...
- 基础系列(1)-- html
(随笔杂谈,自己做的笔记) 网页的组成 结构 ------ xhtml,xml 表现 ------ css 行为 ------ bom,dom,ECMAScript html5结构 < ...