Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Getting 400 (bad request) in swagger after executing the POST api #10247


User avatar
0
shedspotter created
  • What is your product version = 9.0.1
  • What is your product type = Angular
  • What is product framework type = .net core

If issue related with ABP Framework

  • What is ABP Framework version = 5.10.1

Hi , I am calling the API in swagger and it give me 400 (bad request) but when I have tried to execute the same API using POST man I am able to execute the API. So I investigate it furture and check the logs in azure app service , I got an expection when I am trying to do the post call from swagger.It gives me folling error : idateAntiforgeryTokenAuthorizationFilter - The provided antiforgery token was meant for a different claims-based user than the current user. Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The provided antiforgery token was meant for a different claims-based user than the current user.. It's strange as the same API is working correctly in Postman but not in swagger.

Screen shots for log

screen shot of swagger

screen shot of postman using same api

Please provide a solution as soon as possible

Thanks


13 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can reply your swagger html and js files with the latest ones https://github.com/aspnetzero/aspnet-zero-core/tree/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/wwwroot/swagger/ui.

    Then, it should work.

  • User Avatar
    0
    shedspotter created

    Hi ismcagdas , as I have navigated the link shared by you but html and js files not update. last update on these page are 2 yr back

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @shedspotter

    Does this error happen when you visit the website in a incognito mode ?

    Thanks,

  • User Avatar
    0
    shedspotter created

    Hi @ismcagdas , no in normal window we are facing this issue and also now when I am trying to access the API in post man it gives me unsuppoerted media type as error and also I have tried https://support.aspnetzero.com/QA/Questions/6969/Error-405-on-Swagger-with-update-and-delete-service#answer-22bcbe8f-c259-b28b-3e98-39eda8d8ab08 but is not working

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @shedspotter

    Is it possible to share your project with us via email ?

  • User Avatar
    0
    shedspotter created

    Hi @ismcagdas , I will give you the credientials for accessing the application, please share your email

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @shedspotter

    Please send it to [email protected].

    Thanks,

  • User Avatar
    0
    shedspotter created

    I have send it the credientials [email protected]. with ticket

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @shedspotter

    Thanks, got it and will check soon.

  • User Avatar
    0
    shedspotter created

    Hi @ismcagdas is there any update on the above issue

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi **@shedspotter **

    We are working on this but couldn't find a solution yet. I will inform you when we find a solution.

    Thanks,

  • User Avatar
    0
    shedspotter created

    Hi ismcagdas, can I get an update on the issue it is almot 7 month. I am getting the same issue in another project where the get apI's work in swagger but post api is not wokring in swgger every time when I am trying to test the post api is gives me 400 but when same api I am calling from the web ir is working correctly but not in swagger . Can you please resolve that issue as soon as possible ? Thaks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @shedspotter

    We coudln't reproduce this problem somehow. Can you check your project to see if you have a similar issue with this one ? https://github.com/aspnetzero/aspnet-zero-core/issues/2881#issuecomment-570129852