Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RESTful API's - Easy way to interact?



Hey,

I am working on my first full fledge application. Now, my problem lies within that all my data and the main functionality of my application is coming from a RESTful API application on the web. I am having trouble sending headers and configuring the authentication and it just cripples what I do have of my program. So, it would be helpful if someone could explain an easier way than what I am doing to access the RESTful API.

Here is the code I am using to set the headers:

NSString *requestURLWithHeaderAuth(NSURL *url, NSString *headerVal)
{
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"Basic: %@", headerVal] forHTTPHeaderField:@"Authentication"];

return [[[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil] encoding:NSUTF8StringEncoding] autorelease];
}


Now, I need to figure out how to use set GET, but I think that is working. The problem and it is crashing is because it is being encoded by every other method. Here is an example in "pseudo code":

'Basic ' + Base64.encode(username + ':' + password)


Hopefully someone will be able to help, Jeremy

"I have often felt that programming is an art form, whose real value can only be appreciated by another versed in the same arcane art; there are lovely gems and brilliant coups hidden from human view and admiration, sometimes forever, by the very nature of the process. You can learn a lot about an individual just by reading through his code, even in hexadecimal." - Unknown

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.