This project is read-only.

Http Post Issue

Topics: Web Api
Oct 21, 2011 at 10:45 PM

I am facing an interesting issue while using the following POST method:

    [WebInvoke(UriTemplate = "save-blob?fileName={fileName}&container={name}&mime={mime}&zineId={id}&notes={notes}&private={isPrivate}")]
        public HttpResponseMessage SavePhotoArticle1(long id, string name, string mime, bool isPrivate,
            string notes, string fileName, IPrincipal principal, HttpRequestMessage request)

It would appear that while using HTTP Post, if I don't use an HttpRequestMessage<T> then I get the following error:

The HttpOperationHandlerFactory is unable to determine the input parameter that should be associated with the request message content for service operation 'SavePhotoArticle1'. If the operation does not expect content in the request message use the HTTP GET method with the operation. Otherwise, ensure that one input parameter either has it's IsContentParameter property set to 'True' or is a type that is assignable to one of the following: HttpContent, ObjectContent`1, HttpRequestMessage or HttpRequestMessage`1.

The error is primarily because it cannot understand the IPrincipal parameter which is being injected via a Handler.

In other cases where I use POST, but use signature similar to shown below, it works.

 [WebInvoke(UriTemplate = "save-status")]
        public HttpResponseMessage SaveStatus(HttpRequestMessage<ArticleEntity> request, IPrincipal principal)

Now someone could easily mention that I could just remove the Query String parameters and just use the HttpRequestMessage<T> and pass the parameters as an entity. I could do that, but I'm integrating this with WP7 BackgroundTransferRequest which doesn't allow me to specify a POST body and hence I have to build the entire request as a set of Query String Parameters and then perform an HTTP POST with the File contents to the WCF Web API method.

Can anyone please help?

Oct 21, 2011 at 11:07 PM

Could be a bug – could you open an issue in the Issue Tracker and attach a simple project that reproduces the issue so that we can take a look?


Daniel Roth

Oct 22, 2011 at 7:48 AM


I have uploaded my test project on your Issue Tracker. Please advise. I am wrapping up a significant WP7 app and a simultaneous Startup Product so timely assistance or workaround would be highly appreciated.


Thank  You again for your prompt response,

Anup Marwadi

Oct 26, 2011 at 1:46 AM

Hi Anup,

We have found the bug and the fix should be in the future drops. Thanks again for reporting this issue. In the meanwhile, could you work around with HttpRequestMessage<T>?