Solved

This header must be modified using the appropriate property. Parameter name: name

Posted on 2013-01-17
4
1,684 Views
Last Modified: 2013-01-24
Hello Experts
I am trying add headers to the request and I am getting this error, please see the code attached. I wonder if soemone of you can advise what is not correct in here, this is causing me a big grief.
Thanks
  ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf ValidateRemoteCertificate)
            Dim Request As HttpWebRequest = CType(WebRequest.CreateDefault(New Uri(HostUrl & "GenerateReportNow")), HttpWebRequest)
            Request.Method = "PUT"
            'Request.ContentType = "text/xml"
            Request.Headers.Add("Content-Type", "text/xml")
            Request.Headers.Add("Authorization", "BASIC " & Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(UserName & ":" & Secret)))
            Request.Headers.Add("ReportName", "Order")
            Request.Headers.Add("NumberOfDays", "1")


            Dim _Encoding As New ASCIIEncoding()
            Dim ContentData As Byte() = _Encoding.GetBytes(String.Empty)
            Request.ContentLength = ContentData.Length

            Using RequestStream As Stream = Request.GetRequestStream()
                RequestStream.Write(ContentData, 0, ContentData.Length)
                RequestStream.Close()
            End Using

            Dim RetrunContent As String = String.Empty

            ' make the Request
            Using Response As WebResponse = Request.GetResponse()
                ' display the response
                Using ReceiveStream As Stream = (CType(Response, HttpWebResponse)).GetResponseStream()
                    Using ReadStream As StreamReader = New StreamReader(ReceiveStream, Encoding.UTF8)
                        RetrunContent = String.Format("{0}", ReadStream.ReadToEnd())
                    End Using
                End Using
            End Using

Open in new window

0
Comment
Question by:newbie27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 350 total points
ID: 38788771
Try modifying the value instead of adding like:

Request.ContentType = "text/xml"

Similar discussion.
0
 
LVL 8

Author Comment

by:newbie27
ID: 38792268
Hello,
Thanks for your input.
I have had it like before: Request.ContentType = "text/xml"
Their API guide had ("Content-Type", "text/xml") , so I have amended but that did not work either.
Any other suggestion please?
Thanks
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 150 total points
ID: 38792954
Try commenting out all the headers.add calls and uncomment 1 by 1 to see which one is causing the issue.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 38793539
I meant any header with Add that is throwing error must be replaced by property assignment.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question