D
D
dmitriyprog2020-06-20 13:56:54
Xamarin
dmitriyprog, 2020-06-20 13:56:54

How to send a request from Xamarin to the REST API server to change a record in the database?

Hello, I'm sending a request like this

User u = new User("4", "My email.", false , "My Firstname", "", "My Lastname", "", "", "", "City", "10000", "Street", "", "");
            string url = Constants.URL + "/4";
            var client = new HttpClient();
            var json = JsonConvert.SerializeObject(u);
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            var response = await client.PutAsync(url, content);
            Console.WriteLine("Response " + response);


In the database the columns
5eedeb2673631416122167.png

AND the user itself looks like this

class User
    {
        [JsonProperty("id")]
        public string Id { get; set; }

        [JsonProperty("email")]
        public string Email { get; set; }

        [JsonProperty("verified_email")]
        public bool VerifiedEmail { get; set; } // TODO DELETE

        [JsonProperty("username")]
        public string UserName { get; set; }

        [JsonProperty("given_name")]
        public string GivenName { get; set; } // TODO DELETE

        [JsonProperty("family_name")]
        public string FamilyName { get; set; } // TODO DELETE

        [JsonProperty("link")]
        public string Link { get; set; }

        [JsonProperty("picture")]
        public string Picture { get; set; }

        [JsonProperty("gender")]
        public string Gender { get; set; } // TODO DELETE




        [JsonProperty("address_city")]
        public string City { get; set; }

        [JsonProperty("address_plz")]
        public string PLZ { get; set; }

        [JsonProperty("address_street")]
        public string Street { get; set; }

        [JsonProperty("lastvisit")]
        public string LastVisit { get; set; }

        [JsonProperty("created")]
        public string  Created { get; set; }

      //Далее методы, конструкторы и т д


There are no changes in the database

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question