Are you absolutely sure the supplied URL accepts POST requests?  Does the
following command work?

curl -d 'foo=bar&baz=boo' <your url>

Also, I think you might need to close the request stream before you get the
response.

Jackson



On Fri, Feb 17, 2012 at 10:23 AM, Chris House <[email protected]> wrote:

> Greetings – I’m working on my first MonoTouch app (other than Hello World
> of course).  I’m trying to do a POST to a web address so  I can get an
> authentication cookie that will be used in subsequent RESTful calls.  What
> I’m seeing is that when I do the post and include the post data in  the
> request stream, it times out when I call HttpWebRequest.GetResponse().  If
> I remove the line of code that writes to the request stream then I don’t
> get a timeout.  ****
>
> ** **
>
> Here’s what the code looks like:****
>
> ** **
>
> HttpWebRequest authRequest =
> (HttpWebRequest)WebRequest.Create(this.AuthActionUrl);****
>
> authRequest.AllowAutoRedirect = false;****
>
> authRequest.Method = “POST”;****
>
> byte[] postData = this.GetPostData();****
>
> authRequest.ContentType = “application/x-www-form-urlencoded”;****
>
> authRequest.GetRequestStream.Write(postData, 0, postData.Length);  //
> Commenting this line out eliminates the timeout****
>
> authRequest.Headers.Add(Constants.SingleSignOn.COOKIE, string.Joing(“ “,
> cookieJar.ToArray()));****
>
> ** **
>
> using (HttpWebResponse authResponse =
> (HttpWebResponse)authRequest.GetResponse())  // This is where the timeout
> occurs****
>
> {****
>
>   cookieJar.Clear();****
>
>   ProcessCookies(authResponse);****
>
> }****
>
> ** **
>
> Any suggestions would be appreciated.****
>
> ** **
>
> Thanks,****
>
> ** **
>
> Chris****
>
> ** **
>
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to