Key is> hi
Value is> hello
我需要发送此值server.Consider我的网址是https://mywebsite/myserver/upload
如何将这些值在IOS通过使HTTP POST方法发送到服务器。发送键值服务器在IOS
Key is> hi
Value is> hello
我需要发送此值server.Consider我的网址是https://mywebsite/myserver/upload
如何将这些值在IOS通过使HTTP POST方法发送到服务器。发送键值服务器在IOS
这是你如何能为您的请求主体
NSString *myKeyValuePairString = @"hi=hello";
NSData *myRequestData = [NSData dataWithBytes:[myKeyValuePairString UTF8String] length:[myKeyValuePairString length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString: @"https://mywebsite/myserver/upload"]];
[request setHTTPMethod: @"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[request setHTTPBody: myRequestData];
的一部分发送密钥对值,如果为
[request setValue:@"hello" forHTTPHeaderField:@"hi"];
这行说的是什么NSString * myKeyValuePainString = @“hi = hello”;特别是你写了hi = hello。 –
我假设这是你想要的密钥对值作为你的请求体的一部分。如果你想发送它作为一个XML你可以发送一个XML格式。 –
你想寄的是什么头的一部分?请求正文还是作为标题字段? –
作为标题字段 –