Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

15 Experts available now in Live!

Get 1:1 Help Now