问题
I created with offline sync option using azure mobile services. Everything worked fine at the beginning. I inserted several rows and I came back to my app after couple of days when I tried to make an insert into my table. I am getting the error message as
System.ArgumentException: Set JArray values with invalid key value: "version". Int32 array index expected.
at Newtonsoft.Json.Linq.JArray.set_Item (System.Object key, Newtonsoft.Json.Linq.JToken value) [0x00028] in <filename unknown>:0
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.GetJTokenFromResponse (Microsoft.WindowsAzure.MobileServices.MobileServiceHttpResponse response) [0x00035] in <filename unknown>:0
at Microsoft.WindowsAzure.MobileServices.MobileServiceTable+<>c__DisplayClass14+<<InsertAsync>b__13>d__16.MoveNext () [0x000f7] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
I tried to add the version property as below in my todoitem.cs
[Version]
public byte[] Version { get; set; }
or
[TimeStamp]
public byte[] Version { get; set; }
But neither cases helped me. I get the error only when I try to insert. reading data is just fine. Is it expecting me to set something. I thought that it is assigned automatically during a new row insert and used only to verify between row version of data between server and client.
UPDATE: what I changed was after it was working, I changed the schema permissions to "Authenticated users only" for each actions and also added an authentication with google and after that I was keep getting this error whatever I do. I cleaned table on local sqlite and azure but it didnt even help.
回答1:
Finally struggling almost entire 2 days I figure out the problem. I had to use https in my mobileApiUrl while creating MobileServiceClient. This was working fine before I didnt use any authentication on insert and update but once I add authentication with google and facebook, I started getting this error although read queries were still working. i dont know what is the reason behind it but changing from http to https worked like a charm.
MobileService = new MobileServiceClient(Url);
来源:https://stackoverflow.com/questions/36664576/set-jarray-values-with-invalid-key-value-version-int32-array-index-expected