简体   繁体   English

如何将App Service方法用作REST API端点?

[英]How to use App Service methods as REST API endpoints?

POST /api/services/app/Company/Create is the URL we normally get when we create App Service in ASP.NET Boilerplate. POST /api/services/app/Company/Create是在ASP.NET Boilerplate中创建应用程序服务时通常获得的URL。

How can I achieve POST /api/services/app/Company using App Service? 如何使用App Service实现POST /api/services/app/Company Because if I use OData, then some response format is not in ABP response format. 因为如果我使用OData,则某些响应格式不是ABP响应格式。

Here, POST is the HTTP method and Create is the name of the method in CompanyAppService of my ABP Application project. 在这里,POST是HTTP方法,而Create是我的ABP应用程序项目的CompanyAppService中方法的名称。 What I want is when I consume this API on any web app, then I should be able to call this API at /api/services/app/Company with HTTP method POST. 我想要的是在任何Web应用程序上使用此API时,那么我应该能够使用HTTP方法POST在/api/services/app/Company上调用此API。 I don't want to use Create , Update , Delete , Get , GetAll in URL that we are going to use while calling in web application. 我不想在调用Web应用程序时在URL中使用CreateUpdateDeleteGetGetAll

You can achieve this by following way. 您可以通过以下方式来实现。

[HttpPost("api/services/app/Company")]
public async Task CreateCompany(CompanyDetailsDto input)

[HttpDelete("api/services/app/Company")]
public async Task DeleteCompany(EntityDto input)

[HttpGet("api/services/app/Company")]
public async Task GetCompany(EntityDto input)

[HttpPut("api/services/app/Company")]
public async Task UpdateCompany(CompanyDetailsDto input)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM