How do I add custom content to a HttpWebRequest header in VB.Net

Spike UK
Spike UK used Ask the Experts™
I currently have a HttpWebRequest wcustom header written in defined as:

Dim request As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
            request.Method = "POST"
            request.Headers.Add("X-SessionID", sessionID)
            request.ContentType = "application/json; charset=utf-8"

Open in new window

I need to add in the content as below created using PHP/JS.

$options = array(
  'http' =>
  array (
    'method'        => 'POST',
    'header'        => 'X-SessionID: ' . $MY_SESSION_ID . "\r\n" .
                       'Content-Type: application/json',
    'content'       => json_encode($mylist1),
    'ignore_errors'  => true,

Open in new window

How do I do this?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If you read this MS document carefully, you can find out all the answers:

Your request code is almost complete, missing only the data itself. If you read the example code here:
You'll see 1 byte being transmitted. Replace it with text instead (so change to Encoding.ASCII.GetString), and the correct content.


Very clear- thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial