Solved

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

Posted on 2013-01-17
4
1,553 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
  • 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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