Open Closed

Cannot access API from Postman #2669


User avatar
0
lan.dang created
  • ABP Framework version: v5.1
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I am creating API using controller in Blazor project, API works with Get method but not Post method, I call it from Postman and it returns Bad Request. My controller is simple

Here is my Start Up

It works if I runs controller in fresh Blazor project, I want to integrate it to current ABP.IO solution. Please help


4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I call it from Postman and it returns Bad Request.

    Please check the app logs.

  • User Avatar
    0
    lan.dang created

    It seems have this log 2022-03-04 10:18:11.395 +07:00 [INF] Request starting HTTP/1.1 POST https://localhost:44307/api/Values application/json 10 2022-03-04 10:18:11.397 +07:00 [INF] Identity.Application was not authenticated. Failure message: Unprotect ticket failed 2022-03-04 10:18:11.398 +07:00 [INF] Identity.Application was not authenticated. Failure message: Unprotect ticket failed 2022-03-04 10:18:11.398 +07:00 [INF] Identity.Application was not authenticated. Failure message: Unprotect ticket failed 2022-03-04 10:18:11.398 +07:00 [INF] Executing endpoint 'DruidAI.Blazor.Controllers.ValuesController.Post (DruidAI.Blazor)' 2022-03-04 10:18:11.399 +07:00 [INF] Route matched with {action = "Post", controller = "Values", area = "", page = ""}. Executing controller action with signature Void Post(System.String) on controller DruidAI.Blazor.Controllers.ValuesController (DruidAI.Blazor). 2022-03-04 10:18:11.402 +07:00 [ERR] The required antiforgery cookie ".AspNetCore.Antiforgery.qD9znlZol-M" is not present. 2022-03-04 10:18:11.402 +07:00 [INF] Authorization failed for the request at filter 'Volo.Abp.AspNetCore.Mvc.AntiForgery.AbpAutoValidateAntiforgeryTokenAuthorizationFilter'. 2022-03-04 10:18:11.404 +07:00 [INF] Executing ObjectResult, writing value of type 'Microsoft.AspNetCore.Mvc.ProblemDetails'. 2022-03-04 10:18:11.404 +07:00 [INF] Executed action DruidAI.Blazor.Controllers.ValuesController.Post (DruidAI.Blazor) in 5.0763ms 2022-03-04 10:18:11.404 +07:00 [INF] Executed endpoint 'DruidAI.Blazor.Controllers.ValuesController.Post (DruidAI.Blazor)' 2022-03-04 10:18:11.728 +07:00 [DBG] Added 0 entity changes to the current audit log 2022-03-04 10:18:11.730 +07:00 [DBG] Added 0 entity changes to the current audit log 2022-03-04 10:18:11.741 +07:00 [DBG] Added 0 entity changes to the current audit log 2022-03-04 10:18:11.744 +07:00 [INF] Request finished HTTP/1.1 POST https://localhost:44307/api/Values application/json 10 - 400 - application/problem+json;+charset=utf-8 348.5922ms

    What does it mean?

  • User Avatar
    0
    lan.dang created

    And now I got this error when send request from Chrome Plugin 2022-03-04 11:37:00.524 +07:00 [INF] Request starting HTTP/2 POST https://localhost:44307/API/Login application/json 37 2022-03-04 11:37:00.526 +07:00 [DBG] CORS request made for path: /API/Login from origin: chrome-extension://pjidmkdphpgkmfmengaddlpjojjpdifo but was ignored because path was not for an allowed IdentityServer CORS endpoint 2022-03-04 11:37:00.526 +07:00 [INF] No CORS policy found for the specified request. 2022-03-04 11:37:00.527 +07:00 [INF] Executing endpoint 'DruidAI.Blazor.Controllers.APIController.Login (DruidAI.Blazor)' 2022-03-04 11:37:00.527 +07:00 [INF] Route matched with {action = "Login", controller = "API", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task1[Microsoft.AspNetCore.Mvc.ActionResult1[DruidAI.Blazor.Model.LoginRespone]] Login(DruidAI.Blazor.Model.LoginRequest) on controller DruidAI.Blazor.Controllers.APIController (DruidAI.Blazor). 2022-03-04 11:37:00.528 +07:00 [ERR] The required antiforgery header value "RequestVerificationToken" is not present. 2022-03-04 11:37:00.528 +07:00 [INF] Authorization failed for the request at filter 'Volo.Abp.AspNetCore.Mvc.AntiForgery.AbpAutoValidateAntiforgeryTokenAuthorizationFilter'. 2022-03-04 11:37:00.528 +07:00 [INF] Executing ObjectResult, writing value of type 'Microsoft.AspNetCore.Mvc.ProblemDetails'. 2022-03-04 11:37:00.528 +07:00 [INF] Executed action DruidAI.Blazor.Controllers.APIController.Login (DruidAI.Blazor) in 0.8391ms 2022-03-04 11:37:00.528 +07:00 [INF] Executed endpoint 'DruidAI.Blazor.Controllers.APIController.Login (DruidAI.Blazor)' 2022-03-04 11:37:00.533 +07:00 [DBG] Added 0 entity changes to the current audit log 2022-03-04 11:37:00.533 +07:00 [DBG] Added 0 entity changes to the current audit log 2022-03-04 11:37:00.533 +07:00 [DBG] Added 0 entity changes to the current audit log 2022-03-04 11:37:00.534 +07:00 [INF] Request finished HTTP/2 POST https://localhost:44307/API/Login application/json 37 - 400 - application/problem+json;+charset=utf-8 9.3609ms

  • User Avatar
    -1
    maliming created
    Support Team Fullstack Developer

    https://learning.postman.com/docs/sending-requests/cookies/

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11