Define the header in ASIHTTPRequest


I'm using ASIHTTPRequest to access a web based API and need to set a header for App authentication. Note that this is not a server level authentication it is at API level. I've tried every thing I could find and most of the answers on the web as well as the ones here at tell me to use something like:

[request addRequestHeader:@"username" value:@"asdf"];

This does not work for me. The guy who built the API I'm using told me that I need to set the header as:

Authorization: TRUEREST username=PersonName&password=pass&apikey=dfiu6aewruif3Bismillah4Rah3anArahimiImi22MyDad

So I tried the following:

NSURL *url = [NSURL URLWithString:@""];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

[request addRequestHeader:@"username" value:@"MyUser"];
[request addRequestHeader:@"password" value:@"MyPass"];
[request addRequestHeader:@"apikey" value:@"dfiu6aewruif3Bismillah4Rah3anArahimiImi22MyDad"];

But it didn't work... I even tried setting the Request type to GET because the developer told me I should do this:

[request setRequestMethod:@"GET"];

This didn't work... The API developer told me he is made this module as follow:

POST /rest_catches/add.json HTTP/1.1
Authorization: TRUEREST     username=MyUser&password=MyPass&apikey=dfiu6aewruif3Bismillah4Rah3anArahimiImi22MyDad
Cache-Control: no-cache

any help would be greatly appreciated.

You should add only one header is Authorization no need to add separate headers for each field (use, pass, etc).

Fill it with your specific values and send.

[request addRequestHeader:@"Authorization" value:@"TRUEREST username=PersonName&password=pass&apikey=dfiu6aewruif3Bismillah4Rah3anArahimiImi22MyDad"];