This JSON string should be sent:
{
"dashboard": "compact",
"theme": "dark",
"show_side_bar": "yes"
}
in the REST API using the GET method in this format (since the server retrieves the data using this PHP code $_GET["setting"]) s AFHTTPRequestOperationManager, so the equivalent URL will look like this:
http://www.examplesite.com/api/change_setting?setting={ "dashboard" : "compact", "theme" : "dark", "show_side_bar" : "yes" }
When I create the NSDictionaryparameters in AFHTTPRequestOperationManager GET:parameters:success:failure:, which adds the url key parameter to the parameter dictionary, like this:
{
"setting": {
"dashboard": "compact",
"theme": "dark",
"show_side_bar": "yes"
}
}
In short, only the JSON string should be encapsulated in the NOT parameter as an object in JSON.
Edit: Here is the code:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{
kSettingDashboard: @"compact",
kSettingTheme: @"dark",
kSettingShowSideBar: @"yes"
};
[manager GET:kURLChangeSetting
parameters:[NSDictionary dictionaryWithObject:parameters forKey:@"setting"]
success:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
source
share