Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 12, 2012 03:12 AM by BrockAllen
Apr 11, 2012 09:59 PM|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 10:03 PM|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 12, 2012 03:02 AM|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 12, 2012 03:12 AM|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 :)