I'm having a moment I'm sure but I can't work out where the problem stems from.
I've created a new Azure Mobile Service and am trying to insert one piece of data into a table called Product.
Product item = new Product();
item.Name = "Test";
Toast.makeText(MainMenu.this, "" + item.Name, toast.LENGTH_SHORT).show();
mClient.getTable(Product.class).insert(item, new TableOperationCallback<Product>() {
public void onCompleted(Product entity, Exception exception, ServiceFilterResponse response) {
if (exception == null) {
Toast.makeText(MainMenu.this, "Success!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainMenu.this, "" + exception + "", Toast.LENGTH_SHORT).show();
}
}
});
Now I'm setting the item = "TEST" as a string?
public class Product {
public String ID;
public String Name;
}
So my Class for the Mobile Service table is set to accept a string and the Database is asking for
USE [SQLDB]
GO
/****** Object: Table [dbo].[Product] Script Date: 21/08/2016 11:12:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Product](
[id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](100) NULL,
[thetimestamp] [datetime] NULL DEFAULT (getdate()),
[deleted] [bit] NULL DEFAULT ((0)),
[createdAt] [datetimeoffset](7) NOT NULL DEFAULT (CONVERT([datetimeoffset](7),sysutcdatetime(),(0))),
[updatedAt] [datetimeoffset](7) NOT NULL DEFAULT (CONVERT([datetimeoffset](7),sysutcdatetime(),(0))),
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
GO
SET ANSI_PADDING OFF
GO
Now I'm complete confused as to why my app gives me the following error:
com.microsoft.windowsazure.mobileservices.MobileServiceException: {"error":"Invalid data type provided"}
EDIT:
I'm still having this problem despite recreating all of the tables through the Azure Portal with all of the generated columns, I've also tried both VARCHAR (Auto Generated by Azure) and INT Primary Keys.
thetimestamp
column should be a datetimeoffset(7) type - Was this table created by the mobile apps backend? It may be missing required defaults and triggers - Dale Anderson