【c#-API速率限制器】教程文章相关的互联网学习教程文章

c#-如何通过Google Drive .NET API v3使用服务帐户访问Team Drive【代码】

有谁知道应该进行哪些配置才能向Google服务帐户授予对已创建的Team Drive的访问权限? 这个想法是在.NET后端应用程序中使用服务帐户向公司员工之间共享的Team Drive上载文件/从中下载文件.例如,公司拥有其company.com域,并在Google提供name.surname@company.com用户帐户.此外,还有一个面向员工的团队精神.这些帐户之一(不是admin)用于创建服务帐户,到目前为止,这些步骤已完成: >在Google Cloud Platform中为组织创建了一个项目>已...

C#-尝试创建Rest API时获取重复的operationid【代码】

我已经尝试了几个小时才能解决此问题,但我不断收到错误消息:[致命]生成客户端模型时出错:找到具有重复的operationId’recent_items’的操作对象.在API中描述的所有操作中,OperationId必须唯一. 我正在使用Visual Studio 2017Azure SQL数据库C# 我在下面看不到任何重复的operationid(我似乎也无法在此处对其进行整齐的格式化-非常抱歉!){"swagger": "2.0","info": {"version": "v1","title": "azure_items_API"},"host": "azurei...

C#-为Web API创建程序化登录【代码】

我正在尝试使用.net core 2.0中的控制器内的HttpContext.SignInAsync登录以下是我在.net core 1.1中使用的相同控制器,并且工作正常.[Route("Login/{username}")] public async Task<IActionResult> Login(string username) {var userClaims = new List<Claim>{new Claim(ClaimTypes.Name, username),new Claim(ClaimTypes.Role, "custom")};var principal = new ClaimsPrincipal(new ClaimsIdentity(userClaims, "local"));await H...

API正常运行,但参数不接受C#【代码】

我在这里有我的路线前缀:[RoutePrefix("api/Adresses")] public class AdressesController : ApiController {我的功能在这里:[Route("{codeEtudiant}")] // GET: api/Adresses/1 public IEnumerable<Object> getAdresseEtu(Int32 code) {我在哪里调用我的api:using (var client2 = new HttpClient()) {string getasync = "http://localhost:11144/api/Adresses/" + etu.Code;var response2 = await client.GetAsync(getasync);v...

c#-关于Web API请求的滑动会话【代码】

更新:看来它正在尝试在ApplyResponseGrantAsync中写入新的cookie头,但是不能,因为它引发了已经发送了头的异常. 更新:更清楚.如何在Web API请求期间将Set-Cookie标头添加到XHR响应中? TL; DR;问题在于该应用程序已通过MVC进行身份验证,但大量使用了Web API. Web API请求即使使用Authentication属性,也不会滑动会话-几乎可以肯定,因为它是cookie响应. 我有一个组合的MVC和Web API应用程序.在大多数情况下,MVC视图仅加载会发出大量...

C#-Microsoft Graph API将邮件正文作为HTML返回【代码】

我想阅读我的电子邮件并将其转换为json.我正在使用Microsoft Graph API这样查询Office 365邮箱GraphServiceClient client = new GraphServiceClient(new DelegateAuthenticationProvider ((requestMessage) =>{requestMessage.Headers.Authorization =new AuthenticationHeaderValue("Bearer", token);return Task.FromResult(0);}));var mailResults = await client.Me.MailFolders.Inbox.Messages.Request().OrderBy("receivedDa...

C#-缺少googleapis / google / protobuf

我正在尝试从.proto文件here编译GoogleCloudSpeechToTextv1p1beta1的C#库.protobuf编译器有效,但它缺少googleapis / google / protobuf目录中的依赖项.它依赖的所有其他导入文件都存在here. 我的问题是:为什么googleapis/google directory中缺少protobuf目录?是我个人需要编译/汇编的库吗?还是Google应该提供的东西而它却丢失了?解决方法:google / protobuf目录与Google.Protobuf.Tools软件包一起提供,位于工具下(例如,有tools...

c#-调用ASP.NET Core Web API时“ 400 /输入无效”【代码】

我正在使用邮递员测试我的Web API,并在邮递员中返回“ 400错误请求”或“输入无效”.我动作第一行的断点没有被击中.我如何弄清楚幕后发生了什么? 我将显示Postman的屏幕截图,但无法上传图片.这只是一个POST,其中为Body指定了多个字段.这是网址:http://localhost:52126/api/v1/itinerary这是动作:[HttpPost] [Route("api/v1/itinerary")] public async Task<ActionResult> AddItineraryAsync([FromBody] Itinerary itinerary) {i...

c#-在.net核心Web API中自动添加策略属性【代码】

我正在使用.net Core 2.1 Web API.我正在使用基于操作的身份验证.因此,我添加了每个方法[Authorize(Policy =“ …..”)],如下所示.但是,我不想每次都写.我想从方法名称中自动获取策略名称.我该如何实现?namespace University.API.Controllers {[Route("api/[controller]")][ApiController]public class UniversityController : ControllerBase{private readonly IUniversityService universityService;public UniversityControlle...

C#-Web API路由未调用【代码】

这是我的Web API配置:public static class WebApiConfig {public static void Register(HttpConfiguration config){// Web API configuration and services// Web API routesconfig.MapHttpAttributeRoutes();config.Routes.MapHttpRoute(name: "ReaderTags",routeTemplate: "Reader/{readerID}/Tags");config.Routes.MapHttpRoute(name: "DefaultApi",routeTemplate: "{controller}/{action}/{id}",defaults: new { id = RoutePa...

c#-.net webApi中不带id参数的删除请求【代码】

我有如下的.net核心WebApi.而且它运行良好.但是,当我写[HttpDelete]而不是[HttpDelete(“ {id}”)]时,它不起作用.可能是什么原因? 我的网址:http://localhost:5004/api/Student/DeleteStudent/23[ApiController] [Route("api/[controller]/[action]")] public class StudentController : ControllerBase {//[HttpDelete] ///////////////// This is not working[HttpDelete("{id}")] /////////// This is workingpublic async Ta...

C#-Web-API版本控制不适用于默认版本【代码】

我创建了一个带有版本控制的Web API应用程序.我将使用Microsoft.AspNet.WebApi.Versioning包来做到这一点. Webapi配置:public static class WebApiConfig {public static void Register(HttpConfiguration config){// Web API configuration and servicesconfig.AddApiVersioning(o => {o.AssumeDefaultVersionWhenUnspecified = true;});// Web API routesconfig.MapHttpAttributeRoutes();} }我的假设是,如果我没有通过版本,默认...

C#-ASP.Net Core Web API-ICollection没有显示在JSON结果集中【代码】

我正在尝试执行3个proc,以构建客户对象并将其返回给客户端.但是,在我的api(服务器端)内部,我可以正确看到结果.但是,不幸的是,结果集中(客户端)缺少ICollection数据 我正在使用Entity Framework和OData 所以,这是我的模型:public class Customer{[Key]public Guid Id { get; set; }public string Code { get; set; }public string Name { get; set; }public string VatCode { get; set; }public string ChamberOfCommerceCode { ge...

c#-如何在F#Giraffe Web API中检索URL编码形式?【代码】

我正在考虑将C#ASP.NET Core中的WebAPI代码重写为F#Giraffe.但是,对于某些特定的构造,我真的找不到对等的东西,尤其是对于以下类似的东西:[HttpPost("DocumentValidationCallbackMessage")] [Consumes("application/x-www-form-urlencoded")] public async Task<IActionResult> DocumentValidationCallbackMessage([FromForm] string xml) {// Controller Action implementation }AFAIK,长颈鹿中的路由不是由控制器提供动力,而是由...

c# – 在ASP.NET Web API中从URI模型绑定到Dictionary【代码】

请参阅MVC:http://aspnetwebstack.codeplex.com/discussions/351011中的此链接 我遇到模型绑定问题.从JavaScript我执行GET Ajax请求到我的API端点“/ api / products”,传递一些参数,包括分页和排序作为查询参数.这是完整的URI:http://localhost/api/products?page=1&count=10&filter[name]=Test1&filter[price]=10&sorting[name]=desc在服务器端,我有一个Web API控制器从URI接受这些属性:public async IHttpActionResult Get([...