Here's the code snippet I'm working on:
NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:body options:0 error:&error];
NSString *string = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
[request setValue:[[NSString alloc] initWithFormat:@"%d", string.length] forHTTPHeaderField:@"Content-Length"];
[request setValue:string forHTTPHeaderField:@"json"];
[request setHTTPBody:data];
NSLog(@"request.values: %@", [request allHTTPHeaderFields]);
The NSLog returns only the first value:header (i.e. "Content-Length" = 74288), but does not show anything for the value:header containing my string property. I've checked that string exists, it's just really long. My guess is that it's the length of the value field that is causing it not to be set to the header. That, or my JSON format is weird (it's a dictionary containing an array of dictionaries).
Any thoughts?0