How do I send large text in xamarin.ios using HttpClint PostAsync method.

sumitmishrasumitmishra Member ✭✭

Hi,
We have an xamarin.ios native chat app, so i have to send large text in chat using HttpClient or WebClient by rest api.
Here We have sent small text in HttpClient GetStringAsync method but it's crashes the app on large text.
So Please guide me to send large text in xamarin.ios in Wep Api.

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    How did you send the large text? If you are asking how to use the post method to send your request, this code could be helpful:

    string URL = "your-server-url";
    HttpClient _client = new HttpClient();
    
    var post = new PostModel { Title = "Title" };
    var content = JsonConvert.SerializeObject(post);
    var response = await _client.PostAsync(URL, new StringContent(content, Encoding.UTF8, "application/json"));
    
    var jsonString = await response.Content.ReadAsStringAsync();
    
    public class PostModel
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Body { get; set; }
    }
    
  • sumitmishrasumitmishra Member ✭✭

    Hi @LandLu , Thank you for your help,
    Please send the code for asp.net web api method to receive this data. I am unable to find proper solution.

  • LandLuLandLu Member, Xamarin Team Xamurai

    @sumitmishra This is a Xamarin Forum if you want some help about Asp.Net, you should ask questions here: https://forums.asp.net/

Sign In or Register to comment.