title: What is Xamarin Studio's class HttpWebRequest replacement in Objective C?
body: <p>I am pretty much new to Xamarin Studio. and i need to use a functionality in my code which i am writing in Objective C, from another code which in Previously written in Xamarin(C#).</p>
  
  <p>In the Xamarin Code a byte stream of an Image is getting attached to an HttpWebRequest instance. and posted on a server, in order to get a processed image.</p>
  
  <p>I am being unable to find how to use same functionality as the code in xamarin</p>
  
  <pre><code>using (Stream requestStream = httpWebRequest.GetRequestStream ()){}
  </code></pre>
  
  <p>Does.</p>
  
  <p>my Xamarin Code is As Follows :-</p>
  
  <pre><code>HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create (string.Concat (new string[]
          {
              Common.BaseAddress,
              "visualize/",
              GenericHelper.ServiceEncrypt (Common.Token),
              "/",
              Common.AppTag,
              "/",
              Common.ConstructTreatmentSelections ()
          }));
          httpWebRequest.Method = "POST";
          httpWebRequest.ContentType = "application/x-www-form-urlencoded";
          using (Stream requestStream = httpWebRequest.GetRequestStream ())
          {
              int num = 2048;
              int i = 1;
              int num2 = pBytePhotoImage.Length;
              while (i &lt; num2)
              {
                  if (i + num &gt; num2)
                  {
                      num = num2 - i;
                  }
                  requestStream.Write (pBytePhotoImage, i - 1, num);
                  float fProgress = (float)i / (float)num2;
                  if (fProgress &lt;= 1f)
                  {
                      nSAutoreleasePool.InvokeOnMainThread (delegate
                      {
                          pProgressBar.set_Progress (fProgress);
                      });
                  }
                  else
                  {
                      nSAutoreleasePool.InvokeOnMainThread (delegate
                      {
                          pProgressBar.set_Progress (1f);
                      });
                  }
                  i += num;
              }
              nSAutoreleasePool.InvokeOnMainThread (delegate
              {
                  pAnimationImage.StartAnimating ();
              });
          }
  </code></pre>
  
  <p>From searching over the internet what i could gather and implemented was :-</p>
  
  <p>my Objective C code is as follows :-</p>
  
  <pre><code>NSData *data = UIImageJPEGRepresentation(self.imageView.image, 0.2);
  NSString *webServiceURL = @"https://webserviceNameBaseAddress/visualize/lEr0WKCdarv2FLGFvBRbhs41FN7zhgcdiwuEqFtLQINJ|PQpM8HEGQ~~/ios/SL|VL|OC|ML|";
  NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
  [request setURL:[NSURL URLWithString:webServiceURL]];
  [request setHTTPMethod:@"POST"];
  [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  [request setHTTPBody:data];
  [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData * responseData, NSError *err) {
      NSLog(@"URL Response");
      if (err) {
          NSLog(@"Err %@",err.description);
  
      }else
      {
  
          if (responseData) {
              NSLog(@"%@",[UIImage imageWithData:responseData]);
          }
          else{
              NSLog(@"not returning anything");
          }
      }
  }];
  </code></pre>
  
  <p>Now when i run the code in Xcode : 
  the output is :-</p>
  
  <pre><code>Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x75a9ea0 {NSUnderlyingError=0x7189250 "bad URL", NSLocalizedDescription=bad URL}
  </code></pre>
  
  <p>Any help would be great.
  I am stuck at this since two days.</p>
  
  <p>PS :-
  for extracting the webService URL for POST request , from Xamarin App Code.
  what i did was 
  i have printed the URL string out with the help of Consol.WriteLine() in Xamarin
  and then used the exact output in Xcode as NSMutableURLRequest</p>