problems getting HTTPRiot working
Posted
by
bwizzy
on Stack Overflow
See other posts from Stack Overflow
or by bwizzy
Published on 2009-11-24T18:52:02Z
Indexed on
2010/12/22
23:54 UTC
Read the original article
Hit count: 200
I've got an iphone app where I'm trying to use HTTPRiot to make some API calls to a web app. Problem is I can't see that none of the HTTPRiot delegate methods are being called. I've got a log in all the delegate methods, and I'm also looking at the webserver log. I see that the URL is being hit.
//API.h
#import <Foundation/Foundation.h>
#include <HTTPRiot/HTTPRiot.h>
@interface API : HRRestModel {
}
+(void)runTest;
@end
//API.m
#import "API.h"
@implementation API
+ (void)initialize {
NSLog(@"api initialize");
[self setDelegate:self];
[self setBaseURL:[NSURL URLWithString:@"http://localhost:3000/api"]];
[self setBasicAuthWithUsername:@"demo" password:@"123456"];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"1234567" forKey:@"api_key"];
[self setDefaultParams:params];
}//end initialize
+(void)runTest {
NSLog(@"api run test");
// Would send a request to http://localhost:1234/api/people/1?api_key=1234567
[self getPath:@"/save_diet" withOptions:nil object:nil];
}
+(void)restConnection:(NSURLConnection *)connection didReturnResource:(id)resource object:(id)object {
NSLog(@"didReturnResource");
}
+(void)restConnection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response object:(id)object {
NSLog(@"didReceiveResponse");
}
+(void)restConnection:(NSURLConnection *)connection didReceiveParseError:(NSError *)error responseBody:(NSString *)body object:(id)object {
NSLog(@"didReceiveParseError");
}
+(void)restConnection:(NSURLConnection *)connection didReceiveError:(NSError *)error response:(NSHTTPURLResponse *)response object:(id)object {
NSLog(@"didReceiveError");
}
+(void)restConnection:(NSURLConnection *)connection didFailWithError:(NSError *)error object:(id)object {
NSLog(@"didFailWithError");
}
@end
//test code
[API runTest];
//log output
© Stack Overflow or respective owner