beginerdeveloper
beginerdeveloper

Reputation: 845

Azure mobile app Nodejs back end Invalid data type provided

I am trying to insert a row in the table. here are steps what I did :

I run Create table Statement in database to create table test

    Create table test4
(
    id int primary key identity (1, 1),
    name nvarchar(100)
)

then I go to the app service editor and Create file javascript with the name is test4.js

var table = module.exports = require('azure-mobile-apps').table();

then I go to my API and do the insert logic :

var test = {
            name: "test country1",

        };

    req.azureMobile.tables('test4')
        .insert(test)
        .then(() => res.send({
        status: config.get('statusResponse.success'),
        token: 'token'
    })).catch(error => {console.log("error " + error)});

I don't know why I got this error.

error Error: Invalid data type provided

i Update my Question

when I create a table using Easy tables of Azure I can insert records into the table but I want to use the exists table that I created with my tsql

Upvotes: 0

Views: 114

Answers (1)

Bruce Chen
Bruce Chen

Reputation: 18465

error Error: Invalid data type provided

From the statement you provided to create the table:

Create table test4
(
    id int primary key identity (1, 1),
    name nvarchar(100)
)

As 30 DAYS OF ZUMO.V2 (AZURE MOBILE APPS): DAY 6 – PERSONAL TABLES mentioned about the system fields:

The ‘id’ field is a string – it can be anything, but it has to be unique as the id is a primary key. If you don’t specify it, Azure Mobile Apps will assign the string representation of a v4 GUID to this field.

Upvotes: 1

Related Questions