Base solution for your next web application
Open Closed

Dynamic Web API HTTP Request Attributes not working #341


User avatar
0
paulbackhouse created

Hi,

By default all methods are HTTP POST (no problem with this) but I would control over setting methods which should be HTTPGET, HTTPDELETE etc...

I have read you documentation here: [http://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API]) and followed it. I specifically want to use the interface approach where I can define the attributes on the methods I want to have different HTTP Request methods.

However, it does not work, the calls are always being set to POST.

I then tried changing the naming convension during the initialisation of the dynamic controller api using WithConventionalVerbs but this method isn't even available to me, it it not my preferred route either.

I then tried manually setting the verb against the method in the dynamic controller (which I really don't want to have to do) using this code:

DynamicApiControllerBuilder
    .For<IClientService>("app/ClientService")
    .ForMethod("Get").WithVerb(HttpVerb.Get)
    .Build();

Again, no joy.

So....then I thought, fine, I will live for post until I can find a solution here (i.e. post here) BUT my method is:

public ClientDTO Get(long id) { ... }

This doesn't work in POST when the expected parameter type is anything other than an object - even though the value being passed is 7 and you can direct cast to long once in the method... I am very confused - this cannot be default behaviour can it?

What am I missing here, please help, frustrated and struggling - it is far easier in WebAPIControllers :s

Regards

Paul


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Which version of ABP are you using? These are added in v0.7. Please upgrade all Abp.* packages to latest versions.

  • User Avatar
    0
    priteshsanipara created

    I have created on API controller inside WebAPI project. Get and Post both method are shown up in Swagger. but (1) I am not able to call Post method. It run the api but response body is empty. (2) I am not able to call Get method having model as input. It is giving "Null model!" error

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share your api controller definition and how do you call those actions ?

    Thanks.