Re: ios zway authentication - help
Posted: 16 Oct 2015 22:53
Are you not specifying content type for post request?
This is my code, I have not specified content type for post request.pofs wrote:Are you not specifying content type for post request?
Code: Select all
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalAndRemoteCacheData;
[manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"admin" password:@"admin"];
[manager POST:@"http://192.168.0.12:8083/ZAutomation/api/v1/devices/ZWayVDev_zway_2-0-37/command/on" parameters:nil
success:^(AFHTTPRequestOperation *operation, id DATA) {
NSLog(@"notifications: %@",DATA);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"getNotifications Error : %@",error.description);
}];
Thanks pofs. It works now. I thought I should use POST for all the commands sending to the device.pofs wrote:Seems the serializer doesn't specify content type when there's no content.
Why using POST with empty parameters at all?
GET should do the same without this error.