0

I'm developing WP8 application. I need to add data in the url by using the E-mail id and password. I am using webclient(), but I don't know how to do it. Can anyone help me to complete the task? Thanks in advance.

My URL format:

http://xx.xx.xxx.xxx/main/content/api/data/pagename?email=abcd@abcd.com&sig=abcd

This is my url structure. I need to add data for the user above. My Form Design:

![enter image description here][1]

When I click the log-in button I should verify the emailid and password from the above mentioned url structure.

The code below works for posting the data, but I need to know how to post the data by using email and password.

public T Post<T>(string servicePath, string result) 
{ 
    string serviceURL = REST_URI + servicePath; 
    Uri URI = new Uri(serviceURL); 
    System.Net.WebClient webClient = new WebClient(); 
    webClient.Headers["ContentType"] = "application/json"; 
    webClient.Headers["Accept"] = "application/json"; 
    webClient.UploadStringCompleted += this.sendPostCompleted; 
    webClient.UploadStringAsync(URI, HTTP_POST, result); 
    return default(T); 
}
Mathias Müller
  • 22,203
  • 13
  • 58
  • 75
faroke moahmed
  • 313
  • 1
  • 5
  • 19

1 Answers1

0

Try this , here I'm retrieving username and password from text box,

                var username = uname.Text;
                var password = pass.Password;

                var postData = "email=" + username + "&password=" + password;
                WebClient webClient = new WebClient();
                webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
                var uri = new Uri("Your URL here", UriKind.Absolute);
                webClient.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
                webClient.AllowWriteStreamBuffering = true;
                webClient.Encoding = System.Text.Encoding.UTF8;
                webClient.UploadStringAsync(uri, "POST", postData);
                webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(postComplete);
Prasanna Aarthi
  • 3,439
  • 4
  • 26
  • 48