my task is to download an attachment from an IBM server. The problem is that when I do the request with C# - HttpWebRequest and HttpWebResponse, I always get the status code 500 and the response body "Error 500: SRVE0295E: Error reported: 500". But!, when I do the same request with "Postman" there is no error and the file is downloaded. Please pay attention to the fact, that a cookie, which represents the current session, is needed. I added the same cookie (cookie can be reused) to Postman and to my request.
Here is the Http raw request of Postman (I would have posted a screen shot but am lacking reputation points):
https://eforms.ebase.dlh.de:443/forms/secure/org/run/service/ContentStorageService44084
GET /forms/secure/org/run/service/ContentStorageService44084 HTTP/1.1 Host: eforms.ebase.dlh.de:443 Cookie: IPCZQX03e54bbd1d=090038003914048a6f27dcb2bc9b9e0c3a6c63b0; path=/; domain=dlh.de
Postman works (it's really a very simple GET request with only two headers).
And here is the C# code (which returns me the "Error 500: SRVE0295E: Error reported: 500")
HttpWebRequest req = null;
HttpWebResponse res = null;
req= (HttpWebRequest)WebRequest.Create("https://eforms.ebase.dlh.de:443/forms/secure/org/run/service/ContentStorageService44084");
req.Headers.Add("Cookie", "IPCZQX03e54bbd1d=090038003914048a6f27dcb2bc9b9e0c3a6c63b0; path=/; domain=dlh.de");
req.Host = "eforms.ebase.dlh.de";
req.Method = "GET";
try
{
res = (HttpWebResponse)req.GetResponse();
}
catch (WebException ex)
{
res = (HttpWebResponse) ex.Response;
}
Stream receiveStream = res.GetResponseStream();
StreamReader sr = new StreamReader (receiveStream, Encoding.UTF8);
string responseBody = sr.ReadToEnd();
Console.WriteLine((int)res.StatusCode + "\t" + res.StatusCode.ToString());
Console.WriteLine(responseBody);
Any hints will be very much apreciated.
PS: the cookie is OK, without valid cookie I wouldn't even get the "Error 500: SRVE0295E: Error reported: 500". So the error message is from the IBM server, this I can tell for sure.
Thank you in advance.
Johann Kovalenko