質問

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.

役に立ちましたか?

解決

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));
    }

///////

他のヒント

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).

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top