1
votes

I am useing the default server (.net) and default (uwp) app from azure to test the mobile app system.

After publish the server and connect via app to the server i am getting the message "The request could not be completed. (Bad Request)". I am not modified anything. Thats the default project downloaded from azure portal.

The response is:
{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Server: Microsoft-IIS/10.0 Date: Sun, 15 May 2016 18:22:48 GMT X-Powered-By: ASP.NET x-zumo-server-version: net-1.1.157.1 Content-Length: 228 Content-Type: application/json; charset=utf-8 }}

Client to do item:

public class TodoItem
{
    public string Id { get; set; }

    [JsonProperty(PropertyName = "text")]
    public string Text { get; set; }

    [JsonProperty(PropertyName = "complete")]
    public bool Complete { get; set; }
}

Client logic:

    private async void ButtonSave_Click(object sender, RoutedEventArgs e)
    {
        var todoItem = new TodoItem { Text = TextInput.Text };
        TextInput.Text = "";
        await InsertTodoItem(todoItem);
    }

    private async Task InsertTodoItem(TodoItem todoItem)
    {
        // This code inserts a new TodoItem into the database. When the operation completes
        // and Mobile Apps has assigned an Id, the item is added to the CollectionView
        await todoTable.InsertAsync(todoItem);
        items.Add(todoItem);

        //await App.MobileService.SyncContext.PushAsync(); // offline sync
    }

What can i do to run the connection/system?

Thanks

1
Have the same problem. Really confused. Previously worked fine. Suddenly I get this error. I went through all the documentations some suggests that I have permission problems (the backend app cannot generate the table in the database).Sapan Ghafuri

1 Answers

4
votes

I have found that whenever I did one of the following I get this error:

  • When client or server data model does not match the database and neither the client or the server apps does not have permission to change the database tables. In the case you have to either delete all database tables manually in SQL Server Management Studio and run the client to re-generate the tables with the latest changes in the data model. Or you have to apply migrations.

  • When you insert data into a table from the client and the table has foreign key column and you provide a value for the foreign key column while the foreign key table has no values yet.

for example:

var todoItem= new TodoItem
{
    Name = "Buying some food",
    UserId = "1" // this will cause the same error if the user table is empty
};

When you try to insert this item this will cause the same error if the user table is empty