Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with Filesystemobject or .NET version 3 34
Server Error 11 47
ASP.NET 5 Templates 2 65
Help with Syntax 9 26
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now