title: ODataClient The response payload is a not a valid response payload
body: <p>Inner Exception 1:
  DataServiceQueryException: An error occurred while processing this request.</p>
  
  <p>Inner Exception 2:
  InvalidOperationException: The response payload is a not a valid response payload. Please make sure that the top level element is a valid Atom or JSON element or belongs to '<a href="http://docs.oasis-open.org/odata/ns/data" rel="nofollow noreferrer">http://docs.oasis-open.org/odata/ns/data</a>' namespace.</p>
  
  <p>I am getting a very strange error, when I compile the app it compiles once the odata client goes to the database it then crashes with the above error. I have done some research about this and I can see that it is basically looking for the metadata from the odata request. However, I have supplied it, and when i run the uri in postman it works. So my question is what am i doing wrong?</p>
  
  <p>c#:</p>
  
  <pre><code>public const string MetadataDocumentUri = "http://localhost/QuickQuoteApi/odata/$metadata";
  </code></pre>
  
  <p>I get to the controller and it executes fine. Help would be much appreciated </p>
  
  <p>I'm using <code>Devexpres GridControl</code> to access the datasource.</p>
  
  <pre><code>&lt;dx:WcfCollectionViewSource x:Key="WcfCollectionViewSource" 
                                  Culture="en-US" 
                                  ContextType="{x:Type QuickQuote:QuickQuoteContainer}" 
                                  CollectionViewType="{x:Type ListCollectionView}" 
                                  Path="Companies" 
                                  ServiceRoot="http://localhost/QuickQuoteApi/odata/"&gt;
          &lt;dx:DesignDataManager.DesignData&gt;
              &lt;dx:DesignDataSettings RowCount="5"/&gt;
          &lt;/dx:DesignDataManager.DesignData&gt;
      &lt;/dx:WcfCollectionViewSource&gt;
  &lt;/dx:DXWindow.Resources&gt;
  &lt;Grid&gt;
      &lt;dxg:GridControl AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" ItemsSource="{Binding Data, Source={StaticResource WcfCollectionViewSource}}"&gt;
          &lt;dxg:GridControl.View&gt;
              &lt;dxg:TableView AllowPerPixelScrolling="True" ShowTotalSummary="True" IsSynchronizedWithCurrentItem="True"/&gt;
          &lt;/dxg:GridControl.View&gt;
      &lt;/dxg:GridControl&gt;
  </code></pre>
  
  <p>I have also added webapi config</p>
  
  <pre><code>        public static void Register(HttpConfiguration config)
      {
          // Web API configuration and services
  
          // Web API routes
          config.MapHttpAttributeRoutes();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
  
          Microsoft.OData.Edm.IEdmModel edmModel = GetEdmModel();
          config.MapODataServiceRoute("OdataRoute", "odata", edmModel);
  
  
          config.Formatters.Add(new JsonMediaTypeFormatter());
          config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling =
              Newtonsoft.Json.ReferenceLoopHandling.Ignore;
          config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.None;
      }
  
  
  
          private static Microsoft.OData.Edm.IEdmModel GetEdmModel()
          {
              var builder = new ODataConventionModelBuilder();
              builder.Namespace = "QuickQuote";
              builder.ContainerName = "QuickQuoteContainer";
  
              builder.EntitySet&lt;Address&gt;("Addresses");
              builder.EntitySet&lt;Company&gt;("Companies");
              builder.EntitySet&lt;Connector&gt;("Connectors");
              builder.EntitySet&lt;Contact&gt;("Contacts");
              builder.EntitySet&lt;ContactType&gt;("ContactTypes");
              builder.EntitySet&lt;Coordinate&gt;("Coordinates");
              builder.EntitySet&lt;FromTo&gt;("FromTos");
              builder.EntitySet&lt;Manufacturer&gt;("Manufacturer");
              builder.EntitySet&lt;Nc&gt;("Ncs");
              builder.EntitySet&lt;Position&gt;("Positions");
              builder.EntitySet&lt;Product&gt;("Products");
              builder.EntitySet&lt;Question&gt;("Questtions");
              builder.EntitySet&lt;Quote&gt;("Quotes");
              builder.EntitySet&lt;Role&gt;("Roles");
              builder.EntitySet&lt;SingleTerminal&gt;("SingleTerminals");
              builder.EntitySet&lt;TotalHeader&gt;("TotalHeaders");
              builder.EntitySet&lt;TotalItem&gt;("TotalItems");
              builder.EntitySet&lt;TotalLabel&gt;("TotalLabels");
              builder.EntitySet&lt;User&gt;("Users");
              builder.EntitySet&lt;Worksheet&gt;("Worksheets");
              builder.EntitySet&lt;WorksheetLabel&gt;("WorksheetLabels");
  
              return builder.GetEdmModel();
          }
  }
  </code></pre>