您好我是ios开发的新手我想通过http post请求在我的网络服务上发送一些json数据,其中数据将在请求体中而不在参数中?
任何帮助都是赞赏的,谢谢。
答案 0 :(得分:0)
试试此代码
NSURL *url = [NSURL URLWithString:@"Your Json URL"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod:@"POST"];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSString *str = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"responseData in string : %@",str);
NSMutableDictionary *dictTemp = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];
NSLog(@"responseData in Dictionary : %@",dictTemp);
答案 1 :(得分:0)
a.menu {
display: block;
box-sizing: border-box;
padding: 15px;
width: 70px;
height: 60px;
/* other styles */
}