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);
4
  • Can you share your current code? That will make it easier to help you out. Nov 18, 2017 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, 2017 at 15:13
  • This SO post looks like the answer to your question, assuming you intend to use basic username-password authentication. Nov 18, 2017 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, 2017 at 16:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.