web api question

Topics: Core, Customizing Orchard, Troubleshooting, Writing modules
Mar 21, 2014 at 10:18 PM
Edited Mar 21, 2014 at 10:19 PM
I can make a web api project in .net 4.0 and have a controller that has a bunch of [HttpPost] and it works great.


and using a route like this
public static class WebApiConfig
    public static void Register(HttpConfiguration config)
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }

When I create a webapi in a module it does not let me have more than one [HttpPost]

Any reasons for this?

Thanks in advance for you help
Mar 22, 2014 at 4:31 AM
Your sample is strange, using post for a get or an add...
I have several httppost by webapi controller and it runs without pbs from what I remember.
Mar 22, 2014 at 1:22 PM
I can see why you would think it is strange, but we need to pass in security information and product keys for any calls we make. It could be I have something messed up and everyone elses works fine, which is why I am posting here.
Mar 31, 2014 at 10:49 PM
Okay so these shouldn't be a POST as you are not changing the state of the server, instead for authentication you should use an authorization header, and passing any other keys within the querystring....

However! I don't know your architecture, so...

What URL's are you attempting to Post To? You can have many POST's on 1 controller - You just have to specify the URL you are posting to correctly.

i.e. POST: api/<Area Name Here>/persons/get
Mar 31, 2014 at 10:59 PM
I understand its hard not to focus on the reason why I have these as post, but I will be passing in among other things that DO change the state of the server, some api keys that the program witch will be calling these apis will provide to insure its not being used in a manner that is unintended. Getting past that, if I should be able to have more than one post method, on a web api controller inside orchard, then I will look into it further as a bug or something stupid I did. I posted here to ask if there was a reason that I would not be able to do this, thanks for you input. I would love it if this just magically didn't happen in the new release of 1.8 and my problem goes away.