Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)
I have trouble connecting to an OData feed, as I get this error message: "Bad OData Format. Make sure you are using a URL that points to a valid OData Source"

I can access the URL in a browser (and I get the expected JSON response), and I can connect to the OData feed through Excel (Power Query).

Does anyone have a similar problem? And what do you think is the problem?

I am using Tableau 8.1 with Windows 8, and I am developing my OData service through ASP.NET Web API 2.

1 Answer

0 votes
by (47.2k points)
  • While using Web API OData in Tableau Version 9.0, it still has a problem because Tableau requires the data to be in XML format but does not send the Accept header to let the server know it.

  • Here's what worked for me. I modify this code(replacing YourDatabaseEntities and YourTable) and add it for each controller that Microsoft scaffolding creates :

public class YourTableController : ODataController

{

    /// <summary>

    /// The database

    /// </summary>

    private YourDatabaseEntities db = new YourDatabaseEntities();

    /// <summary>

    /// Adds Accept header for Tableau which requires XML data but doesn't send a header requesting it

    /// </summary>

    protected void FTLP()

    {

        try

        {

            Request.Headers.Remove("Accept");

        }

        catch { }

        try

        {

            Request.Headers.Add("Accept", "application/atom+xml");

        }

        catch { }

    }

    // GET: odata/YourTable

    /// <summary>

    /// Gets the Your Table.

    /// </summary>

    /// <returns>IQueryable&lt;YourTable&gt;.</returns>

    [EnableQuery]

    public IQueryable<YourTable> GetYourTable()

    {

        FTLP();//Add this to Fix Tableau XML requirement 

        return db.YourTable;

    }

    // GET: odata/YourTable(5)

    /// <summary>

    /// Gets the YourTable.

    /// </summary>

    /// <param name="key">The key.</param>

    /// <returns>SingleResult&lt;YourTable&gt;.</returns>

    [EnableQuery]

    public SingleResult<YourTable> GetYourTable([FromODataUri] DateTime key)

    {

        FTLP();//Add this to Fix Tableau XML requirement 

        return SingleResult.Create(db.YourTable.Where(YourTable => YourTable.Date == key));

    }

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 19, 2019 in BI by Vaibhav Ameta (17.6k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...