Forum Cross Platform with Xamarin
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

can you please help me how to display the post data

HiralBhayaniHiralBhayani USMember
edited December 2017 in Cross Platform with Xamarin
    private async static void PostJson(string uri, Organization postParameters)
    {
        var client = new HttpClient();
        client.BaseAddress = new Uri(uri);
        string postData = JsonConvert.SerializeObject(postParameters);
        var content = new StringContent(postData, Encoding.UTF8, "application/json");
        HttpResponseMessage response = await client.PostAsync("organizationts/postorganizationt", content);
        int statusCode = (int)response.StatusCode;
         var result = await response.Content.ReadAsByteArrayAsync();
        //  byte[] bytes = Encoding.UTF8.GetBytes(postData);

        if (statuscode >= 200 && statuscode < 300)
         {


        }

Answers

  • seanydaseanyda GBMember ✭✭✭✭✭

    @HiralBhayani said:

        private async static void PostJson(string uri, Organization postParameters)
        {
            var client = new HttpClient();
            client.BaseAddress = new Uri(uri);
            string postData = JsonConvert.SerializeObject(postParameters);
            var content = new StringContent(postData, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync("organizationts/postorganizationt", content);
            int statusCode = (int)response.StatusCode;
             var result = await response.Content.ReadAsByteArrayAsync();
            //  byte[] bytes = Encoding.UTF8.GetBytes(postData);
    
            if (statuscode >= 200 && statuscode < 300)
             {
    
               
            }
    

    You will want to do the updates to the UI in here.

    if (statuscode >= 200 && statuscode < 300)
             {
    
    
            }
    

    It looks like you're expecting a byte[] response from the web service, So in the above brackets you need to do what you want with the bytes whether that's streaming a PDF document or whatever.

Sign In or Register to comment.