3

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 developping my OData service through ASP.NET Web API 2.

cuongle
  • 74,024
  • 28
  • 151
  • 206
bamine
  • 43
  • 1
  • 6
  • 1
    Try to use fiddler to track the http request/response of get OData feed, Verify if it is OData issues or Power Query issue? – Maya May 14 '14 at 03:33
  • Which kind of URL are you using in Tableau? The service document or a specific entity set. I think Tableau only handles the latter. – vc 74 May 07 '15 at 11:25

3 Answers3

4

Tableau Version 9.0 still has this problem when using Web API OData, it's doing it 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 :

/// <summary>
/// Class YourTableController.
/// </summary>
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));
    }

///////

  • Tableau shouldn't have to send the accept header as the spec specifies the default format is atompub (http://www.odata.org/documentation/odata-version-2-0/operations/). I agree it's always better to specify it though... – vc 74 May 07 '15 at 11:23
1

Check for error messages in the Tableau log here: My Documents > My Tableau Repository > Logs > log.txt

In our case we saw Tableau appended $inlinecount=allpages to the OData URL, which fails in OData v4 with:

{"error":{"code":null,"message":"The system query option '$inlinecount' is not defined."}}

Tableau only supports OData v2. Denodo can support both versions. We installed v2 and we were able to connect successfully. Here is feedback from Tableau Support:

According to this article from Microsoft, the inlinecount function was not included in OData version 4: https://msdn.microsoft.com/en-us/library/dd942040.aspx. This is one of the reasons why Tableau Desktop cannot connect to that version of OData.

The only Tableau documentation I could find documenting the OData V2 requirement was this:

Tableau connects to OData V2, and does not support browsing OData service documents. http://onlinehelp.tableau.com/current/pro/online/windows/en-us/help.htm#examples_odata.html

We originally were concerned about json vs. atom formats based on other answers here, but this was not issue for us. Once we got the connection working, we realized that Tableau cannot use a live connection to OData so we reverted back to ODBC anyways!

TL;DR Make sure you are using OData V2 and not using an OData service document (as of August 2016, Tableau v 9.3.5 and below).

TheRizza
  • 1,577
  • 1
  • 10
  • 23
0

There are 2 options to resolve this issue:

  1. Add 'application/json' to the Accept header.
  2. Append $format to the original URL, e.g., ~/Employees?$format=application/json

Now in the latest ODL(6.3), only json is supported for payloads except metadata document.

Tan Jinfu
  • 3,327
  • 1
  • 19
  • 20
  • If you explicitely request json as the format, Tableau will send back an error as it only accepts AtomPub – vc 74 May 07 '15 at 11:47