views:

29

answers:

1

This relates to my other question on accessing a REST service that uses forms authentication, but I feel it is substantially enough a discrete issue.

When I paste a REST call into my browser address bar, before I am authenticated, I am redirected to a login page on the services web site. I log in and receive a cookie, which authenticates subsequent REST calls or user oriented page requests.

When I recreate the login screen locally and perform the same HTTPS POST that the online login screen performs, I get the error 422 - Unprocessable Entity. I have compared my POST request and that from their login screen, and there are precisely two headers that differ, being "Referer" and "Cookie". Even when I set these headers in my request to the same as in their request, I still get the same error.

+1  A: 

Any REST call you are typing into your address bar is an HTTP GET (or HTTPS GET) not POST -

maybe this is the problem?

just change

<form method="POST">

to

<form method="GET">
Jiaaro
No, the call I type in is a get, it redirects to the login page which does a post - I don't type the login post it, I post it from a replica of their login form.
ProfK
hmm... does their documentation suggest that you do that? I would think allowing remote sites to POST to your login form could be a security problem.They're probably requiring a session cookie to stop people from doing exactly that
Jiaaro