-3
.NET 서버에 게시 요청이 작동하지 않습니다.iOS의 JSON 게시가 작동하지 않습니다 (.NET 서버)
{"CreatedBy":"","EmailAddress":"[email protected]","Zipcode":"","FirstName":"devan","DeviceCategoryID:":"","State":"","CustomerTypeID:":"",..........} like this.....
하지만 JSON 개체는 다음과 같아야합니다 :
NSDictionary *jsonDict = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
NSURL *postURL = [NSURL URLWithString: @"SOME URL"];
NSError *error=nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:0 error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: postURL
cachePolicy: NSURLRequestUseProtocolCachePolicy
timeoutInterval: 60.0];
[request setHTTPMethod: @"POST"];
[request setValue: @"application/json" forHTTPHeaderField: @"Accept"];
[request setValue: @"application/json" forHTTPHeaderField: @"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d",[jsonData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: jsonData];
NSLog(@"JSON summary: %@", [[NSString alloc] initWithData:jsonData
encoding:NSUTF8StringEncoding]);
출력은 내가 게시에 대한 닷넷 서버를 사용하고
({CreatedBy:"",EmailAddress:"[email protected]",Zipcode:"",FirstName:"devan",DeviceCategoryID::"",State:"",CustomerTypeID:"" })
.
요청은 서버에 게시되지 않습니다. 누구든지 나를 도와주세요.
출력이 올바르게 표시됩니다. 10 분을 소비하고 [JSON 형식] (http://www.json.org)을 배우십시오. 서버 측에서이 json을 구문 분석 할 수없는 경우 문제는 다른 곳에 있습니다. – Mar0ux
언제든지 http://json.parser.online.fr/을 사용하여 출력을 확인할 수 있습니다. – Mar0ux