tags:

views:

6

answers:

0

I am trying upload a NameValueCollection to a web service. My name value collections are bunch of records that I need to send from a C# client to my webservice. Now, on the service side, in debug mode, I keep getting error, Format exception for the integer values I had uploaded. e.g.

NameValueCollection data = new NameValueCollection();
foreach (var response in Responses) {
data.Add("sessionid", response.SessionID); data.Add("videoid", response.VideoID.ToString()); } string reply = PostRequest(webServiceURL, data);

On the service side, SessionID is fine because its already a string, but videoID is not, A System.Format exception is thrown saying videoid is not a valid int64, although on the client side I have declared videoID as ulong.

Now inside PostRequest I have the following

try { client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; byte[] output = client.UploadValues(address, data); string response = client.Encoding.GetString(output); return response; } catch (Exception ex) { Error(this, new ErrorEventArgs(ex)); return null; } When I upload a single NameValueCollection i.e. without the foreach loop, it works fine. As soon as I use the loop, things mess up. What am I doing wrong here??