Pass parameter in json format to consume service post in app xamarin.forms

0

In my App I have this method to consume the service post (still writing the method):

public async Task<string> PostIndicador(string jsonValue)
{
    client = new HttpClient();
    string url = $"http://meu_ip/indicadorservice/indicadorservice.svc/metdodoservico";
    HttpContent content = new StringContent(jsonValue, Encoding.UTF8, "application/json");
    var uri = new Uri(string.Format(url));
    var response = await client.PostAsync(uri, content);

    string responseMessage = await response.Content.ReadAsStringAsync();
    return responseMessage;
}

The question is: How do I pass the parameter in json format to this method? The parameter comes in the argument jsonValue .

A clarification only: Should I pass in the URL the method that is in Service(metdodoservico) ?

  

P.S. Another company developed the Service, so I do not have access to   nothing.

EDIT1

My model

public class TipoIndicador
    {
        public int IDUsuario { get; set; }
        public int IdTipoIndicador { get; set; }
        public decimal ValorPrevisto { get; set; }
        public decimal ValorRealizado { get; set; }
    }
    public class Indicador
    {
        public List<TipoIndicador> tipoIndicador { get; set; }
    }

EDIT2

public async Task<string> PostIndicador(string jsonValue)
        {            
            string url_base = $"meu_ip";
            var uri = new Uri(string.Format(url_base));
            using (var client = new HttpClient() { BaseAddress = uri })
            {
                var responeMessage =
                await client.PostAsync("/indicadorservice/indicadorservice.svc/metdodoservico", new StringContent("jsonValue", Encoding.UTF8, "application/json"));
                var resultcontent = await responeMessage.Content.ReadAsStringAsync();
                return (JsonConvert.DeserializeObject(resultcontent)).ToString();
            }
        }
    
asked by anonymous 11.01.2018 / 15:58

0 answers