#StackBounty: #c# #azure #azure-mobile-services #patch #bad-request Azure Mobile App – UpdateAsync – waiting for activation "Error…

Bounty: 50

I have two projects

First is Mobile App with Xamarin.Forms

Second is Windows Form Application

and both have the same API that was created using Azure Mobile App.

in Windows form
when I’m trying to update a row in the database with a.Net HttpClient using the following code :

private void BtnUpdateUser_Click(object sender, EventArgs e)
        UserRepository userRepository = new UserRepository();
        var user = userRepository.GetAllUsers().Select(s => s).Where(w => w.UserId == 1).FirstOrDefault();

        user.UserName = "UpdateUserName";

        var result = userRepository.UpdateUser(user.Id, user);

In UserRepository class I have a method called UpdateUser

public User UpdateUser(string id, User user)
        var result = Task.Run(async () => await azureServices.UpdateAsync(id, user)).Result;
        return result;

In AzureServices class I have a method called UpdateAsync

public async Task<T> UpdateAsync(string id, T instance)

        var Uri= new Uri(baseAddress + id + zumoAddition); //"http://localhost:55040/tables/User/48D68C86-6EA6-4C25-AA33-223FC9A27959?zumo-api-version=2.0.0
        var content = JsonConvert.SerializeObject(instance);
        await _httpClient.PatchAsync(Uri, new StringContent(content, Encoding.UTF8, "application/json"));

        return instance;

PatchAsync is an extension method to do a PATCH request with the Windows.Web.Http.HttpClient

public static async Task<HttpResponseMessage> PatchAsync(this HttpClient Client, Uri requestUri, HttpContent contnet)

        var method = new HttpMethod("PATCH");
        var httpRequestMessage = new HttpRequestMessage(method, requestUri)
            Content = contnet

        var httpResponseMessage = new HttpResponseMessage();
            httpResponseMessage = await Client.SendAsync(httpRequestMessage);
        catch (TaskCanceledException e)
            Debug.WriteLine("Error: " + e.ToString());
        return httpResponseMessage;

in this line httpResponseMessage = await Client.SendAsync(httpRequestMessage); I get this error:

{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
x-zumo-server-version: net-2.0.0
Date: Thu, 29 Nov 2018 10:20:59 GMT
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Content-Length: 188
Content-Type: application/json; charset=utf-8

In the backend I have a controller with a Patch method:

public Task<User> PatchUser(string id, Delta<User> patch)
         return UpdateAsync(id, patch);

when I try debugging the backend I get this:

Id = 179, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"

enter image description here

The question is:How I can get rid of this error and why it appears.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.