[Node.js][Mobile Apps] xhr_proxy error when querying azure mobile app backend with apache/cordova RRS feed

  • Question

  • i am using an apache/cordova project in Visual Studio with an azure mobile app back end.

    When i download the pre-created project for the todoitem table i can query that table fine and data displays correctly when i run the app  in the Ripple-iPhone5 simulator. However, any other table i have in the same database i get the following error:

    Failed to load resource: the server responded with a status of 404 (Not Found)


    If i connect to my database within visual studio and run a simple query against the other table the data does exist; so i am not trying to query an empty table

    Tuesday, April 5, 2016 7:03 PM


All replies

  • You need to define the table in your Azure Mobile App.  This involves either adding the table in Easy Tables or defining a table in the /tables directory with the same name as the table.  See this document:
    Tuesday, April 5, 2016 9:03 PM
  • Is the only reason the todoitem table works is because its an EasyTable and the others were created with T-SQL within SQL Server Object Explorer?

    If i have many tables and constraints it seems like Easy Tables is going to be difficult.

    The link you sent has about 25 'how to' things listed; i am not sure what specifically i am looking for here or where the /tables directory can be found.

    any help would be appreciated..thanks

    Tuesday, April 5, 2016 9:51 PM
  • There is a specific question in there on "HOW TO Create a Table Controller".

    You are right - using Easy Tables for complex situations is probably  not ideal.  If you care about your SQL tables and are not just using them as a store, then Easy Tables is unlikely to match the experience you are after.  You will want to work on a specific coded backend in ASP.NET or Node.js (depending on your needs) and you will use SQL Server Management Studio to manage the server - you won't be using Easy Tables.

    Wednesday, April 6, 2016 12:36 AM
  • See on how to define a table definition file. You just need a JavaScript file that describes the schema in the database.
    Wednesday, April 6, 2016 12:42 AM
  • I did not see that specific HOW TO in the link....?

    I did initially create the node.js backend so i could use an apache/cordova app within visual studio so I didnt make any changes on that piece. 

    Wednesday, April 6, 2016 12:10 PM
  • i need to do this process for every table?

    Is there a more detailed example anywhere on creating PKs, FKs etc to my other tables

    For example, in T_SQL i would do this to link two of my tables together.

    CREATE TABLE [dbo].[allTeams]
    [teamId] INT NOT NULL
    [teamName] NVARCHAR (20) NOT NULL,
            [teamAbbr] NVARCHAR (3) NOT NULL,

    CREATE TABLE [dbo].[players]
    [playerName] NVARCHAR (25) NOT NULL, 
    [playerPosition] NVARCHAR (5) NOT NULL, 
    [teamId] INT NOT NULL, 
        CONSTRAINT [FK_players_allTeams] FOREIGN KEY ([teamId]) REFERENCES [allTeams]([teamId])

    Wednesday, April 6, 2016 12:12 PM
  • Yes, you need to define each table that you want to expose to the mobile devices, including the view of that table.  You can do this in ASP.NET or Node.js (and by extension the Portal), but it has to be done.  We don't expose your entire database - just the tables that you tell us to expose.

    Wednesday, April 6, 2016 7:51 PM
  • I am pretty confused by this option. If i have a 100 tables and some of them with hundreds of rows i need to manually populate them one by one! That does not make sense at to me.

    I still dont understand why i can not use Visual Studio to connect to my Azure SQL DB and then use SQL commands to create and populate my tables which is much easier.

    Why would the Visual Studio option not work?

    Wednesday, April 6, 2016 9:08 PM
  • You don't need to manually populate the rows, just the schemas for the tables you want to expose. The JavaScript file does not create tables, it is just metadata for the tables. You create the actual database tables the usual way, using SQL.

    If you don't want to do this manually, just export your database schema in SQL and just do a simple text transform to map the tables to JavaScript.

    Wednesday, April 6, 2016 11:54 PM
  • OK, that helps some.....

    Do you have any links for examples on creating schema with PK/FK relationships? This link did have a basic example, but errored on the keyword 'require'.

    Also, an examples on exporting the database schema as you mention in your last statement?

    Thursday, April 7, 2016 1:37 PM
  • You should look at the example table schema when you create an easy table. It's the same for all tables. You only need to map JavaScript types, not PK/FK relationships.

    What is the error you get on the "require" keyword?  Where do you see the error? 

    I don't have an example on how to create the database schema, it was just a suggestion on a way to avoid doing everything manually. You just need a simple text transform to map column names, using a regex find and replace in a text editor.

    For instance, you need to change [playerName] NVARCHAR (25) NOT NULL to "playerName": "string". You can only use JavaScript types here.

    Friday, April 8, 2016 4:56 PM
  • I can easily modify the NVCARH to string and some of the others to int etc...

    But, i will need PK/FK relationships in my tables. Based on what i copied and pasted in my post a few days ago on my two tables, you can see the players table references the team table. Is that possible or should/can i just change that AFTER my tables are created within Visual Studio/SQL Object Manager?

    As far as the error on the 'require' keyword (here is my code snippet). I underlined the error i am getting on the java console.....

    (function () {

        document.addEventListener('deviceready', onDeviceReady, false);

        function onDeviceReady() {

        function tableCreate() {
            var azureMobileApps = require('azure-mobile-apps'); "Uncaught ReferenceError: require is not defined"

            var testtable = azureMobileApps.table();

            // Define the columns within the table
            testtable.columns = {
                "ownersId": "int",
                "ownerName": "string"

            // Turn off dynamic schema
            testtable.dynamicSchema = false;
            module.exports = testtable;


    Friday, April 8, 2016 5:16 PM
  • You can't specify PK/FK relationships in the JavaScript table definition file. It is only there to map database table names and column names to JavaScript types.

    If there is an error, it wouldn't be in the JavaScript console, it would be in your log file for your site. Are you trying to add this code on the mobile client?  That's not where it goes, it needs to be in your site setup.

    Friday, April 8, 2016 6:51 PM
  • where do i add this code within site setup?

    Friday, April 8, 2016 7:01 PM
  • Please read the documentation, it's all explained there:
    Friday, April 8, 2016 7:03 PM
  • this is the doc i have been working on, but it does not mention how to 'find' the javascript file in the tables directory....i just dont see a tables directory anywhere..

    Friday, April 8, 2016 7:11 PM
  • It is impossible for you to have a working site with no Tables directory. Are you going to Easy Tables -> Edit Script?  What are the contents there?

    Adding new tables without Easy Tables is more advanced, so I recommend that you learn learn how to add server scripts with Easy Tables first. 

    Friday, April 8, 2016 10:22 PM
  • well, it has taken me a long time for this, but i finally found the tables directory. Seemed difficult to find documentation on where this is located and what you need to do to create to table schema.

    So, i uploaded a few tables with schema and everything finally looks OK here.

    i will add the data to the tables and manage the PK/FK contraints via SQL Object exporter in Visual Studio.


    Saturday, April 9, 2016 2:27 AM