"Cannot populate JSON array for type" When trying insert data

403 Views Asked by At

Update: After all day messing with this, I fixed it. I Changed my mobileserviceclient URL to include https instead of HTTP. I think this was causing my post to instead be a get request that returned an array of "Comment" and tried to parse it to a single "Comment" therefore the error.

Having trouble debugging this, I have the following table/class:

public class Comment
    {
        public string Content { get; set; }
        public string UserId { get; set; }
        public string MenuItemId { get; set; }
    }

Using AzureMobileServiceClient I can get data from the Azure Mobile App into my Xamarin App so the JSON returned from the client must be getting deserialized into my Comment type but when I try to add data using the following code:

var comment = new Comment
                {                         
                    Content = NewComment,
                    MenuItemId = Item.Id,
                    UserId = App.CloudService.CurrentUser.UserId
                };

                await App.CloudService.client.GetTable<Comment>().InsertAsync(comment);

I get the error "Cannot populate JSON array onto type 'Comment'"

I can insert the data fine using postman definitely something wrong on the client-side. I saw one other question on this and they said they fixed it by deleting the project and remaking but I'd rather figure out what is actually happening.

0

There are 0 best solutions below