I send POST request to the server, my login has a dot inside for ex:"Log.in",
POST /api/users/Log.in/albums/ HTTP/1.1
Content-Type: application/atom+xml; charset=utf-8; type=entry
Authorization: FimpToken realm="website.com", token="XXX"
Host: website.com
Content-Length: 255
...data...
Server respond:
HTTP/1.1 302 FOUND
Server: nginx
Date: Sat, 30 Oct 2010 10:03:55 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Location: http://website.com/api/users/log-in/albums/
0
So, I've got a redirect with "Log-in" instead of "Log.in" but my request did not created a photo album on "website.com". If I send POST request directly to Log-in url I get Authorization error. What should I do to redirect my post request with all authorization data ?
Here is the code:
HttpWebRequest request = WebRequest.Create(this._userAlbumsURL) as HttpWebRequest;
request.Method = RequestType.POST.ToString();
request.ContentType = "application/atom+xml; charset=utf-8; type=entry";
request.Headers.Add(HttpRequestHeader.Authorization,
String.Format(@"FimpToken realm=""website.com"", token=""{0}""",this._token));
Stream requestStream = request.GetRequestStream();
Atom10ItemFormatter atomFormatter = new Atom10ItemFormatter(atomEntry);
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
using (XmlWriter writer = XmlWriter.Create(requestStream, settings))
{
atomFormatter.WriteTo(writer);
}
requestStream.Close();
try
{
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
StreamReader reader = new StreamReader(response.GetResponseStream());
Console.WriteLine(reader.ReadToEnd());
}
catch (WebException e)
{
throw new WebException(e.Message);
}