views:

55

answers:

1

How can I check a webservice if the username/password is correct?

I don't want to transfer the whole response body. I only want to know if the username/password exists and is correct. Currently I'm sending a request to my webservice like this:

self.request = [ASIHTTPRequest requestWithURL:urlObject];
[self.request setUsername:username];
[self.request setPassword:password];
[self.request addRequestHeader:@"Accept" value:@"application/json"];
[self.request setDelegate:self];
[self.request startAsynchronous];

If I access the webservice with a browser and I insert a wrong password, I again get the authentication dialog displayed. I tried the same in Xcode and I get a status code = 200 if password was wrong. I thought I can do that with the status codes like 401 and so on. But that didn't worked, because I always get status code = 200. Do I have to change something on the serverside?

I'm using a REST webservice, which uses Restlet 2.0 as Java framework. Docs

A: 

I'm still not sure exactly how your webservice works, but from the information given I think I can answer your question.

If you are getting 'requestFailed:' when the username and password is wrong, then you should be able to avoid downloading the response body by using:

[request setRequestMethod:@"HEAD"];
JosephH