Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-17
4
Medium Priority
?
1,977 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 1400 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 600 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 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