Note that there are some explanatory texts on larger screens.

plurals
  1. POposting data to PHP from C#
    primarykey
    data
    text
    <p>HI I have been trying to post data to PHP webservice(3rd party) from my C# code. The PHP webservice says it expects a parameter <code>c</code> (missing parameter <code>c</code> is the error I get). I am using JSON to send the data, but i do not understand how do give the parameter. Would be great if some one could throw light on this.The following is my code:</p> <pre><code>DropYa d = new DropYa(); List&lt;DropYaUser&gt; d1 = new List&lt;DropYaUser&gt;(); DropYaUser ds = new DropYaUser(); ds.action = "create"; ds.groupid = 10; ds.name = "Test"; ds.manager_key = "test"; d1.Add(ds); WebRequest request = WebRequest.Create(" http://dev.dropya.net/api/Group.php"); // Set the Method property of the request to POST. request.Method = "POST"; // Create POST data and convert it to a byte array. JavaScriptSerializer ser = new JavaScriptSerializer();//typeof(DropYaUser)); string postData = ser.Serialize(ds); byte[] byteArray = Encoding.UTF8.GetBytes(postData); // Set the ContentType property of the WebRequest. request.ContentType = "application/json"; // Set the ContentLength property of the WebRequest. request.ContentLength = byteArray.Length; // Get the request stream. Stream dataStream = request.GetRequestStream(); // Write the data to the request stream. dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object. dataStream.Close(); Console.Write("Wrote"); Console.Read(); // Get the response. WebResponse response = request.GetResponse(); // Display the status. Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. Console.Read(); dataStream = response.GetResponseStream(); Console.Read(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); // Display the content. Console.WriteLine(responseFromServer); // Clean up the streams. reader.Close(); dataStream.Close(); Console.Read(); response.Close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload