Problem with simple JavaScript OData Client RRS feed

  • Question

  • Hi All,

    I'm just trying to make a simple javascript client application to hit a wcf data service.  I created an asp page in order to do that.  The call hits the service, however, the service responds with a 501 not implemented error.  The code is as follows:



    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind="Default.aspx.cs" %>

    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script type="text/javascript" src="scripts/start.debug.js"></script>
    <script type="text/javascript" src="scripts/start.js"></script>
    <script type="text/javascript" src="scripts/System.Web.Extensions/MicrosoftAjaxCore.js"></script>


    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" >

    <script type="text/javascript">

        var dataContext;
        Sys.require([Sys.components.dataView, Sys.components.adoNetDataContext, Sys.components.openDataContext, Sys.scripts.OpenData, Sys.components.openDataServiceProxy]);
        Sys.onReady(function () {
            dataContext = Sys.create.openDataContext(
                serviceUri: "http://odata.netflix.com/v1/Catalog/",
                mergeOption: Sys.Data.MergeOption.appendOnly


      <div id="Demo1" xmlns:sys="javascript:Sys" xmlns:dataview="javascript:Sys.UI.DataView" sys:activate="*">
            <tr class="tableHeader">
            <td>Symbol Code</td>
            <tbody sys:attach="dataview"
            dataview:dataprovider="{{ dataContext }}"
            <td>{{ Name }}</td>




    From monitoring the interactions with Fiddler, I think the problem lies in the fact that my program is attempting to access the service using an HTTP OPTIONS instead of HTTP GET.  HTTP OPTIONS doesnt seem to be supported.  So I guess my question is is there any way to specify using the openDataContext the HTTP verb that I want to use, or for another service (not the Netflix one, but one that I create) is there any way to enable the HTTP OPTIONS verb for that wcf data service?  I'll include the Fiddler request/response below:



    OPTIONS http://odata.netflix.com/v1/Catalog/Genres HTTP/1.1
    Host: odata.netflix.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20100914 Firefox/3.6.10
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Origin: http://localhost:60026
    Access-Control-Request-Method: GET
    Access-Control-Request-Headers: maxdataserviceversion,x-requested-with


    HTTP/1.1 501 Not Implemented
    Cache-Control: private
    Content-Length: 222
    Content-Type: application/xml
    Expires: Wed, 20 Oct 2010 02:36:13 GMT
    Vary: *
    Server: Microsoft-IIS/7.0
    DataServiceVersion: 1.0;
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Date: Wed, 20 Oct 2010 02:35:43 GMT

    <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
    <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
      <message xml:lang="en-US">Not Implemented</message>


    Any help would be greatly appreciated.


    Wednesday, October 20, 2010 2:36 AM

All replies

  • did you ever figure this out??? I am having the same problem. It would be realkly helpful if someone would answer!
    Tuesday, November 30, 2010 1:34 AM
  • You can do the same thing with JQuery. Is that a option for you ?
    Tuesday, December 14, 2010 7:57 PM
  • As noted above you can do something similar using JQuery or I suggest taking a look at DataJS which is a javascript library that makes consuming OData sources from Javascript simple. Check it out here: http://datajs.codeplex.com .  I used DataJs to create validator.odata.org and it should reduce your overall code a fair amount.

    Mike Flasko WCF Data Services/OData Team, Senior Program Manager Lead
    Sunday, April 24, 2011 10:21 PM