Last post Apr 11, 2012 11:12 PM by BrockAllen
Apr 11, 2012 05:59 PM|sbrown999|LINK
I'm trying to comsume a REST webservice. I give it a date (encoded to remove the slashes) and an interval.
wsURL += HttpUtility.UrlEncode(startDate.ToShortDateString()) + "/" + interval;
Here is the url string encoded, as expected.
Below is my code:
WebRequest request = WebRequest.Create(uri) as HttpWebRequest;
XmlSerializer ser = new XmlSerializer(typeof(eTraceEvents));
WebResponse response = request.GetResponse();
eTraceEvents result = (eTraceEvents)ser.Deserialize(response.GetResponseStream());
And here is the url after creating the webrequest object:
Notice the encoding is GONE.
Apr 11, 2012 06:03 PM|BrockAllen|LINK
I'm no encoding expert, but don't those mean the same thing? A "/" can be represented as a "/" or "%2F". It's like saying the number "one" can be represented as "1" or "one" or "I" (roman numeral).
Apr 11, 2012 11:02 PM|sbrown999|LINK
Yes, sorta. The problem the web service is expecting 2 parameters, delimited by the slash, just like any restful web service. What it gets is 4 parameters which it has no idea what to do with and proceeds to tell me to get lost. i don't wanna get lost,
i wanna get my data.
Apr 11, 2012 11:12 PM|BrockAllen|LINK
Sure, I understand that routing is making a distinction in segments and thus "/" is special but you're sending extra "/" characters via your date param (despite the encoding). Anyway, like I said I'm no encoding or URL spec expert... have you considered
passing the date differently or look into
wildard params? Just trying to help :)