Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP POST in .NET doesn't work
    primarykey
    data
    text
    <p>I've got a problem with creating an HTTP post request in .NET. When I do this request in ruby it does work.</p> <p>When doing the request in .NET I get following error:</p> <pre><code>&lt;h1&gt;FOXISAPI call failed&lt;/h1&gt;&lt;p&gt;&lt;b&gt;Progid is:&lt;/b&gt; carejobs.carejobs &lt;p&gt;&lt;b&gt;Method is:&lt;/b&gt; importvacature/ &lt;p&gt;&lt;b&gt;Parameters are:&lt;/b&gt; &lt;p&gt;&lt;b&gt; parameters are:&lt;/b&gt; vacature.deelnemernr=478 &lt;/b&gt;&lt;p&gt;&lt;b&gt;GetIDsOfNames failed with err code 80020006: Unknown name. &lt;/b&gt; </code></pre> <p>Does anyone knows how to fix this?</p> <p>Ruby:</p> <pre> require 'net/http' url = URI.parse('http://www.carejobs.be/scripts/foxisapi.dll/carejobs.carejobs.importvacature') post_args = { 'vacature.deelnemernr' => '478', } resp, data = Net::HTTP.post_form(url, post_args) print resp print data </pre> <p>C#:</p> <pre> Uri address = new Uri(url); // Create the web request HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest; // Set type to POST request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; // Create the data we want to send StringBuilder data = new StringBuilder(); data.Append("vacature.deelnemernr=" + HttpUtility.UrlEncode("478")); // Create a byte array of the data we want to send byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString()); // Set the content length in the request headers request.ContentLength = byteData.Length; // Write data using (Stream postStream = request.GetRequestStream()) { postStream.Write(byteData, 0, byteData.Length); } // Get response using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { // Get the response stream StreamReader reader = new StreamReader(response.GetResponseStream()); // Console application output result = reader.ReadToEnd(); } return result; </pre>
    singulars
    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