I am provided a webservice url similar to: http://ericdev35:7280/persons/persons/ and a username and password.
I want to make a post call on this web service from WPF application. The data to be sent to the service is the first name and last name of a person in the format: "fname=Abc&lname=Xyz"
How can I make a call for this in C#? Here is the code that I have tried:
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create("http://ericdev35:7280/persons/persons/");
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/json";
httpWebRequest.Credentials = new NetworkCredential(username, password);
string data = "fname=Abc&lname=Xyz";
StreamWriter writer = new StreamWriter(httpWebRequest.GetRequestStream());
writer.Write(data);
writer.Close();
This does not give me any error but I cannot see the data that I have posted. Is there anything that needs to be corrected? Is the Content Type correct?