none
Forcing atom+xml output from WebAPI 2 OData Service RRS feed

  • Question

  • I'm trying to create a WebAPI 2 OData service to expose data for use in SAP Business Intelligence Information Design Tool (v4.1 SP2). This SAP BI tool is able to consume OData v2.0 services.

    Using Mike Wasson's tutorials (http://code.msdn.microsoft.com/ASPNET-Web-API-OData-cecdb524) as a starting point, I'm able to use SAP to consume the service's metadata (seeing the data sets and columns available). I'm also able to submit a $select request through the service, which I wasn't able to do when I started with a VS2012 example project from http://msdn.microsoft.com/en-us/magazine/dn201742.aspx. It appears that $select support via WebAPI OData was added with VS2013.

    The problem I have now, though, is that the WebAPI OData service returns data serialized in the jsonLITE format, which is an OData v3.0 introdution. SAP BI is choking on the results with "ParseError at [row,col]:[1,1], Message: Content is not allowed in prolog." I think the SAP tool only supports the older, more verbose atom+xml format.

    Mike Wasson's tutorial says to use Accept headers to request results via different serializations. However, the SAP BI tool doesn't send any Accept headers, and I can't find any place in the tool to specify Accept headers (I've got a separate question out in that realm).

    Can anyone show me how to force atom+xml output in the absence of Accept headers? i.e. to manually override the default jsonLITE output?

    Thursday, January 9, 2014 6:46 PM

Answers

  • OK, solved it myself.

            // GET odata/Products
            [Queryable]
            public IQueryable<Product> GetProducts()
            {
                if (Request.Headers.Accept.Count == 0)
                    Request.Headers.Add("Accept", "application/atom+xml");

                return db.Products;
            }

    Thursday, January 9, 2014 8:16 PM

All replies

  • OK, solved it myself.

            // GET odata/Products
            [Queryable]
            public IQueryable<Product> GetProducts()
            {
                if (Request.Headers.Accept.Count == 0)
                    Request.Headers.Add("Accept", "application/atom+xml");

                return db.Products;
            }

    Thursday, January 9, 2014 8:16 PM
  • Hi,

    I am very glad that you have solved your problem by yourself, if you have any other problem, welcome to post it in this forum.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 10, 2014 5:55 AM
    Moderator