I am making an API call in which the Parameters are as:
{
name : XYZ,
marks : { maths : 34 }
}
I am using JSON model for making API calls and handling the response.
Here is how I made params Dict:
NSMutableDictionary *paramsDict = [[NSMutableDictionary alloc] init];
NSMutableDictionary *marksDict = [[NSMutableDictionary alloc] init];
[marksDict setObject:"34" forKey:"maths"];
[paramsDict setObject:marksDict forKey:@"marks"];
[paramsDict setObject:@"XYZ" forKey:@"name"];
Here Goes my API CALL
APIManager *apimanager = [[APIManager alloc] init];
apimanager.delegate = self;
[apimanager getServerDataWithParam:paramsDict apiMethodType:kAPIMethodTypePOST andMapperClass:[StudentMarks class]];
My App Crashes giving me this Crash Log
Assertion failure in +[JSONHTTPClient urlEncode:], /Users/Documents/JSONHTTPClient.m:122
2016-08-12 12:46:16.653 ClassMgmt[30227:1338857] *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'request parameters can be only of NSString or NSNumber classes.
'{ maths = 34; }' is of class __NSDictionaryM.'
I don't want to convert my NSDictionary
to NSString
using:
[NSString stringWithFormat:@"@", aDictionary];
Is their any other way I can send NSDictionary
as a value in POST
Request as a parameter?