orthehelper
orthehelper

Reputation: 4079

Post String to a server

i need to send this SomeString To a server by a post request. without to make it NSData object and do NSUTF8StringEncoding the SetHttpBody: ask me only for a NSData object. how can i Post this String

SomeString = @"registerRecipt.aspx?udid=962c3486-a8d6-4c32-9ff8-7b255cce4d65&receipt=ewoJInNpZ25hdHVyZSIgPSAiQW1wMnhiVGxYTGg5UmhFUUlCMzNLMHdZdHl3Tnd0WWFVaEdKQzNoUE04Rm8wSys4NE5wWkdWdWRFRndjQ0k3Q2draVluWnljeUlnUFNBaU1TNHdJanNLZlE9PSI7CgkiZW52aXJvbm1lbnQiID0gIlNhbmRib3giOwoJInBvZCIgPSAiMTAwIjsKCSJzaWduaW5nLXN0YXR1cyIgPSAiMCI7Cn0="

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://someUrl.com/"]];
request.timeoutInterval = 20;
[request setHTTPMethod:@"POST"];
[request setHTTPBody:SomeString];
[[NSURLConnection alloc] initWithRequest:request delegate:self];

Upvotes: 0

Views: 176

Answers (2)

CarlJ
CarlJ

Reputation: 9481

  1. For easy development use ASIHTTPRequest
  2. your JSON in the Base64 String isnt valid.
  3. UDID is deprecated use insted the mac adress from your iphone

Upvotes: 0

Tom van der Woerdt
Tom van der Woerdt

Reputation: 29985

You can use [SomeString dataUsingEncoding:NSUTF8StringEncoding];

Upvotes: 2

Related Questions