博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
api 创建实体,返回id
阅读量:2384 次
发布时间:2019-05-10

本文共 1123 字,大约阅读时间需要 3 分钟。

public HttpResponseMessage Post(Employee employee){int maxId = list.Max(e => e.Id);employee.Id = maxId + 1;list.Add(employee);var response = Request.CreateResponse
(HttpStatusCode.Created, employee);string uri = Url.Link("DefaultApi", new { id = employee.Id });response.Headers.Location = new Uri(uri);return response;}客户端     HttpClient client = new HttpClient();            // Send a request asynchronously continue when complete              client.GetAsync(_address).ContinueWith(                (requestTask) =>                {                    // Get HTTP response from completed task.                      HttpResponseMessage response = requestTask.Result;                    // Check that response was successful or throw exception                      response.EnsureSuccessStatusCode();                    var products = response.Content.ReadAsAsync
>().Result;                    foreach(var pro in products)                    {                        string text = pro.FoodName;                    }                 }

转载于:https://my.oschina.net/u/942328/blog/233661

你可能感兴趣的文章
PHP - 解决中文乱码问题
查看>>
js页面跳转整理
查看>>
在64位Win7操作系统中安装Microsoft Access Engine的解决方案
查看>>
30类CSS选择器
查看>>
微信支付的使用介绍
查看>>
PHP单例模式应用详解
查看>>
冒号课堂§5.2:数据类型
查看>>
博客搬家
查看>>
冒号课堂§6.2:平台语言
查看>>
《关于信息系统组织方式的一个提案》的评论与反评
查看>>
冒号和他的学生们(连载10)——超级范式
查看>>
冒号和他的学生们(连载9)——泛型范式
查看>>
冒号和他的学生们(连载13)——范式总结
查看>>
A Proposal on Organization of Information System
查看>>
冒号和他的学生们(连载2)——首轮提问
查看>>
正则表达式与文件格式化处理
查看>>
Java EE互联网轻量级框架整合开发
查看>>
Java语言程序设计(基础篇)
查看>>
大型网站技术架构:核心原理与案例分析
查看>>
JAVA并发编程实战
查看>>