1

I want to not put JSON data in the body AND use a parameter in the URI

I am able to get JSON data through by using something like this.

[WebInvoke(Method = "POST",
    UriTemplate = "Checkin/SetPicture/{PatientProfileId}",
    BodyStyle = WebMessageBodyStyle.Bare, // this is key for combining params with Stream
    ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]

Stream SetPicture(string PatientProfileId, PictureData data);

and PictureData - very simple:

[DataContract]
class PictureData {
    [DataMember]
    internal string Base64 { get; set; }
}

If I post something like this it works (from the REST console/client)

    http://localhost:9001/Checkin/SetPicture/666
    Content-Type:  application/json
    Body - 
{ "Base64": "AAAAAA" }

If I want just the Base64 string in the body, and not JSON, how do I do it? Right now it gives a response back of "Server Error - check logs", but of course there is nothing in the log. It's a parsing issue from the contract since the class is never hit.

ie Body - 

AAAAAA

Here is a related SO query but doesn't quite get me what I need.

Passing XML string in the body of WCF REST service using WebInvoke

Community
  • 1
  • 1
Rob
  • 2,363
  • 7
  • 36
  • 54
  • See this http://stackoverflow.com/questions/28137314/how-to-accept-parameters-including-images-through-a-json-web-service-and-store/28137858#28137858 – EZI Jan 29 '15 at 19:53
  • Thanks, i tried it but still has the same generic 'server error'. I would think that approach would work, not sure what I am missing. – Rob Jan 29 '15 at 20:10

0 Answers0