Question

I have web service urls that were working fine and are now returning the following error: UriTemplate does not support "{}" as a valid format for a segment or a query part.

I normally work on the files in Visual Web Developer 2010 Express. The only thing that I did between them working and not working (that I can think of) is that I worked on the files in a Professional version of Visual Studio 2010. Then I saved them, and opened am now working on them again in Express. (I checked the .sln files and they are identical.)

(Update) The rest of the post describes the problem in more detail, but this is what I think caused the problem: VS 2010 Professional edited a config file (or some file) and this broke the solution when it was subsequently opened up in Visual Web Developer 2010 Express. But I haven't been able to figure out which file(s) got edited. Maybe someone can tell me which files are suspect. Its not any in MyRootDirectory/Properties. I tried those.

Problem details:

This url used to work and now it throws the error above

http://localhost:52631/WebServices/gg.svc/GetStoresForDropdown

This url used to work and also is now returning the same error.

http://localhost:52631/WebServices/gg.svc/StoreGroceryTable?UserId=1&StoreId=2

The request is not getting to my code page. - break points there don’t get hit.

Here is the top of the stack trace. I think that, somehow, my url is getting modified before it gets there.

[FormatException: UriTemplate does not support '{}' as a valid format for a segment or a query part.] System.UriTemplateHelpers.IdentifyPartType(String part) +3049859

System.UriTemplateQueryValue.CreateFromUriTemplate(String value, UriTemplate template) +49

System.UriTemplate..ctor(String template, Boolean ignoreTrailingSlash, IDictionary`2 additionalDefaults) +1004

The WebGet attributes for the two methods are:

[WebGetAttribute(UriTemplate = "GetStoresForDropdown", ResponseFormat = WebMessageFormat.Json)]
[WebGetAttribute(UriTemplate = "StoreGroceryTable?UserId={UserId}&StoreId={StoreId}", ResponseFormat = WebMessageFormat.Json)]

I get the same results using these browsers: IE8, Chrome, FireFox

ideas?

Was it helpful?

Solution

I would look for any of the web methods, not necessarily the one you are having problems with, that has something like this:

[WebInvoke(UriTemplate = "(some url)?Param1={}&..."]

It is very easy to declare a UriTemplate and forget to add the parameter name inside {}.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top