我正在向服务器发送 json 数据并出现错误
json -
- { GETDatetime = "/日期(1354119549)/"; }
错误 -
- 服务器在处理请求时遇到错误。异常消息是“SqlDateTime 溢出。必须介于 1753 年 1 月 1 日上午 12:00:00 和 9999 年 12 月 31 日晚上 11:59:59 之间。
obj-c 中的代码
NSString* json = [dict JSONRepresentation];
//NSString *myRequestString = @"param="; // Attention HERE!!!!
//myRequestString = [myRequestString stringByAppendingString:json];
NSURL *url = [NSURL URLWithString:reqUrlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSData *requestData = [NSData dataWithBytes:[json UTF8String] length:[json length]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];