Nimish
Nimish

Reputation: 1

WCF Rest | URL parameters not working GetProduct/{productid}/{format}

I have a WCF REST Based Service method with URL of two parameters

/GetProduct/{productid}/*{format}

Format expects "xml" to give output in xml and if nothing is provided it returns in JSON. The issue is if enter format as "xml" or any string equal to more than 2 characters, it breaks with an exception "Length cannot be less than zero. Parameter name: length"

If I give just one characters like "x" it works. This is quite strange. Any insights in this.

Operation Contract

[WebGet(ResponseFormat= WebMessageFormat.Json , BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetProduct/{productid}/{*format}")]
Product GetProduct(String productid, String format);

Upvotes: 0

Views: 212

Answers (1)

Satchi
Satchi

Reputation: 477

If your objective is to get XML or JSON output for the service without any code change. Please have a look at my answer

WCF REST return single method as JSON and XML

Hope that helps.

Upvotes: 0

Related Questions