First of all I am new to C#. I am writing a WPF program in Visual Studio 2019.
In my project I have multiple web requests and whilst testing how they work the functionality was minimal: only the web requests were made and they were working fine until now. The login authorization request still works.
This is my webrequest.
using (var client = new WebClientEx())
{
client.BaseAddress = serverurl.serviceurl;
client.UseDefaultCredentials = true;
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(excelvertibas.username + ":" + excelvertibas.password));
client.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
client.Timeout = 90000;
byte[] postArray = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(domObjectVariables));
client.Headers.Add("Content-Type", "application/json");//----------------
client.Encoding = Encoding.UTF8;
byte[] responseArray = client.UploadData(serverurl.serviceurl + "StartAddDigitalObject", "post", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(domObjectVariables))); //----------------------------
domMetadataAddResponse = JsonConvert.DeserializeObject<StartAddDigitalObjectResponse>(Encoding.UTF8.GetString(responseArray));
}
The base address works, I tested it manually through Postman.
Username and password are also correct which I have tested.
Post array is also passing information which is needed, and I have checked it whilst adding breakpoints.
My question is why could this be not working anymore and what should I look for?
fyi this is the line of code where is should be getting information back into the response array but for some reason it stays null.
byte[] responseArray = client.UploadData(serverurl.serviceurl + "StartAddDigitalObject", "post", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(domObjectVariables)));
After this the program breaks because the response array contains nothing when I try to pass it further.
question from:
https://stackoverflow.com/questions/65847738/why-am-i-not-getting-anything-from-my-webrequest-what-am-i-supposed-to-look-for 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…