0

Hello everyone I am currently working on a Post Method of my C# work. As the URL I am going to send request to requires username and password, I have it but I do not know how to include them in my code. How should I insert them into my code?

Here is my request:

Content-Type: multipart/related; boundary="myboundary"
From: 12345678
To: 12345678
Password: my_Password
Username: my_UserName

--myboundary
Content-Type: application/smil
Content-ID: <abc.smil>
Content-Location: abc.smil

Here are my code:

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://myurl.com");
        request.Method = "POST";
        request.ContentType = "multipart/related; boundary = myboundary";
        WebResponse response = request.GetResponse();
        Console.WriteLine(((HttpWebResponse)response).StatusDescription);
WongKH
  • 11
  • 2
  • Can you share your current code? That will make it easier to help you out. – ThePretendProgrammer Nov 18 '17 at 15:05
  • @ThePretendProgrammer yes I have just edited my questions with my code. I have just started it so it may not be a detailed one... – WongKH Nov 18 '17 at 15:13
  • [This](https://stackoverflow.com/questions/25852551/how-to-add-basic-authentication-header-to-webrequest) SO post looks like the answer to your question, assuming you intend to use basic username-password authentication. – ThePretendProgrammer Nov 18 '17 at 15:41
  • @ThePretendProgrammer Thank you so much, can u please also check my requirements? I am new to C# so please I need some help.. Thanks!! – WongKH Nov 18 '17 at 16:00

0 Answers0