I have a problem with setting the HTTPBody of a request correctly. I'm using Oauth to communicate with our API server, the only difference is, that I need to send the data through body, not the header (using OauthConsumer.framework - http://code.google.com/p/oauthconsumer/wiki/UsingOAuthConsumer).
This is my code:
NSString *oauthHeader = [NSString stringWithFormat:@"OAuth realm=\"%@\", oauth_consumer_key=\"%@\", %@oauth_signature_method=\"%@\", oauth_signature=\"%@\", oauth_timestamp=\"%@\", oauth_nonce=\"%@\", oauth_version=\"1.0\"%@",
[realm URLEncodedString],
[consumer.key URLEncodedString],
oauthToken,
[[signatureProvider name] URLEncodedString],
[signature URLEncodedString],
timestamp,
nonce,
extraParameters];
//[self setValue:oauthHeader forHTTPHeaderField:@"Authorization"];
NSLog(@"%@", oauthHeader);
[self setHTTPBody:[oauthHeader dataUsingEncoding:NSASCIIStringEncoding]];
This is the output of NSlog.
OAuth realm="", oauth_consumer_key="key", oauth_signature_method="HMAC-SHA1", oauth_signature="HT2UwJoW4dSNh1gXkAzQThLp0Sk%3D", oauth_timestamp="1340789377", oauth_nonce="3BDF0A1A-4FB0-40EF-95EA-5CB8B0FD07C1", oauth_version="1.0"
And this is what server reads, why the array is wrong? It's not server side bug, our C# client does it without any problem.
array(1) { ["OAuth_realm"]=> string(215) """, oauth_consumer_key="key", oauth_signature_method="HMAC-SHA1", oauth_signature="HT2UwJoW4dSNh1gXkAzQThLp0Sk=", oauth_timestamp="1340789377", oauth_nonce="3BDF0A1A-4FB0-40EF-95EA-5CB8B0FD07C1", oauth_version="1.0"" }