title: IOS Application to send data to a REST API service content-type definition error
body: <p>I managed to make an application to send data to a rest api service. The content type must be text/html. But whenever i run my app i get a 415 http code response which means not supported type of content. Here is my code:</p>
  
  <pre><code>NSURL *url = [NSURL new];
  
  NSData *body = nil;
  
  NSString *contentType = @"text/html"; 
  
  NSURL *finalURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://telesto.zapto.org:81/SMART_EdgeNode/EdgeNode/DataFeeds/3/addMeasurement"]];
  NSString *yourString = @"geoX#35#geoY#65";
  
  
  
  
  
  contentType = @"application/x-www-form-urlencoded; charset=utf-8";
  
  body = [[NSString stringWithFormat:@"%@", yourString] dataUsingEncoding:NSUTF8StringEncoding];
  NSString *putLength = [NSString stringWithFormat:@"%d",[body length]];
  
  
  
  if (nil==finalURL) {
  
      finalURL = url;
  }
  
  
  NSMutableDictionary* headers = [[[NSMutableDictionary alloc] init] autorelease];
  [headers setValue:contentType forKey:@"Content-Type"];
  [headers setValue:@"mimeType" forKey:@"Accept"];
  [headers setValue:@"no-cache" forKey:@"Cache-Control"];
  [headers setValue:@"no-cache" forKey:@"Pragma"];
  [headers setValue:@"close" forKey:@"Connection"];
  
  
  
  
  
  
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:finalURL
                                                         cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                     timeoutInterval:60.0];
  [request setHTTPMethod:@"PUT"];
  
  [request setAllHTTPHeaderFields:headers];
  
  
  [request setHTTPBody:body];
  [request setValue:putLength forHTTPHeaderField:@"Content-Length"];
  
  self.conn = [NSURLConnection connectionWithRequest:request delegate:self];
  </code></pre>
  
  <p>I guess atm there is something wrong with defining the content-type . Any help??</p>
  
  <p>Thanks in advance</p>