Disallowed Key Characters as a response

217 views
Skip to first unread message

Jakub Jurkiewicz

unread,
Mar 14, 2010, 10:44:17 AM3/14/10
to ASIHTTPRequest
Hello,

Recently I have started using ASIHTTPRequest. It's great! however, I
got to the point which stops me from going forward.
I use ASIFormDataRequest to post data to polish microblogging service
called flaker.pl. When I try to sumbit the request I receive
responseStatusCode=200 (which means everything was OK), but in the
responseString I find: "Disallowed Key Characters".

One guy who was trying to post to flaker.pl with python had the same
problem and he found out that it was base64.encodestring issue (it
was adding some additional character to the authorisation data).

Any idea what may be wrong?

The simplest version of my code is following:
[code]
- (BOOL)updateStatus:(NSString *)status forUsername:(NSString
*)username withPassword:(NSString *)password {
NSURL *url = [NSURL URLWithString:@"http://api.flaker.pl/api/
type:submit"];
ASIFormDataRequest *request = [ASIFormDataRequest
requestWithURL:url];
[request addBasicAuthenticationHeaderWithUsername: username
andPassword: password];
[request setPostValue:@"text" forKey:status];
[request setRequestMethod:@"POST"];

[request startSynchronous];

int statusCode = [request responseStatusCode];
if (statusCode == 200) {
return YES;
} else {
return NO;
}
}

[/code]

Thanks!

Ben Copsey

unread,
Mar 15, 2010, 4:21:33 AM3/15/10
to asihttp...@googlegroups.com
Hi Jakub

Hmm, not sure. If the problem is related to the base64-ed authorization header, you might try something like this:

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

[request setUsername:username];
[request setPassword:password];


[request setPostValue:@"text" forKey:status];

[request setShouldPresentCredentialsBeforeChallenge:NO];
[request startSynchronous];

This will only send the authorization header after the server asks for it, and CFNetwork will construct the header rather than ASIHTTPRequest, so if the problem is with the way ASIHTTPRequest is base64-ing the data, this might resolve the issue.

If you can post a username and password that trigger this (obviously, not your real username and password!), I'll take a look later today.

Best

Ben

Jakub Jurkiewicz

unread,
Mar 15, 2010, 8:21:38 AM3/15/10
to ASIHTTPRequest
Hello Ben,

Thanks for your suggestion! Unfortunately, it does not resolve the
issue.
I use the following credentials for testing purposes:
username: PostItTest
password: PostItTest20

Any help is much appreciated.

kind regards,
Jakub

Ben Copsey

unread,
Mar 16, 2010, 6:31:26 AM3/16/10
to asihttp...@googlegroups.com
Hi Jakub

> Thanks for your suggestion! Unfortunately, it does not resolve the
> issue.
> I use the following credentials for testing purposes:
> username: PostItTest
> password: PostItTest20

When I test with this username and password, I'm just getting an http authentication error, so I'm not able to see the response.

From the API docs here:

http://blog.flaker.pl/api-dodawanie-tresci/

It looks like your problem may be here:

[request setPostValue:@"text" forKey:status];

If I'm reading it right, this should be:

[request setPostValue:status forKey:@"text"];

Best

Ben

Jakub Jurkiewicz

unread,
Mar 16, 2010, 10:16:12 AM3/16/10
to ASIHTTPRequest
On 16 Mar, 11:31, Ben Copsey <b...@allseeing-i.com> wrote:
> From the API docs here:
>
> http://blog.flaker.pl/api-dodawanie-tresci/
>
> It looks like your problem may be here:
>
> [request setPostValue:@"text" forKey:status];
>
> If I'm reading it right, this should be:
>
> [request setPostValue:status forKey:@"text"];

Yes, this was the case! I don't know how could I have mixed that.
Thanks a lot for your help!

kind regards,
Jakub

Reply all
Reply to author
Forward
0 new messages