locked
A missing or empty content type header was found when trying to read a message. The content type header is required RRS feed

  • Question

  • In the code below I am getting the following error message:

    A missing or empty content type header was found when trying to read a message. The content type header is required

    The error appears in the foreach loop.

    Any idea how to get or set the content type header?

    static void Main(string[] args)
            {
                Uri serviceUri = new Uri("https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZGWSAMPLE_SRV", UriKind.Absolute);

                ServiceReference1.ZGWSAMPLE_SRV context = new ServiceReference1.ZGWSAMPLE_SRV(serviceUri);

                context.Credentials = new System.Net.NetworkCredential("user", "password");

                var query = from b in context.BusinessPartnerCollection
                            select b;

                foreach (var myObject in query)
                {
                    Console.WriteLine("\n email: {0} | Phone number : {1}", myObject.EmailAddress, myObject.PhoneNumber);

                }
            }

    On the browser I get this response:

    1. Status Code: 200 OK
    2. Content-Type: application/xml
    3. Server: SAP NetWeaver Application Server / ABAP 702
    4. dataserviceversion: 2.0
    5. ntcoent-length: 2526

    Tuesday, July 30, 2013 6:10 PM