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.

Parse JSON reponse

I log on to the website in the answer I get json where is the name, surname and x-ticket etc... I need to get an x-ticket to put it in local storage. How can I do this to get only x-ticket content from the result?

                        string DIRECT_POST_CONTENT_TYPE = "application/x-www-form-urlencoded";
                        string URL = "https://asdasd/api/1.3/login";
                        HttpClient client = new HttpClient();
                        string postData = "email=asdasd&password=asd";

                        StringContent content = new StringContent(postData, Encoding.UTF8, DIRECT_POST_CONTENT_TYPE);
                        HttpResponseMessage response = await client.PostAsync(URL, content);

                        var result = await response.Content.ReadAsStringAsync();

                    } catch (Exception ex)
                        await DisplayAlert("teste", ex.Message, "ok");

It's my json response:
{"sales":"{\u0022success\u0022:false,\u0022message\u0022:[\u0022No owner specified\u0022],\u0022contactId\u0022:null,\u0022externalId\u0022:null}","user":{"id":111,"name":"test","surname":"asdas","email":"[email protected]","group_id":3,"avatar_image_url":"null","employment_place":"null","position":"tester","description":"","plan":null},"x-ticket":"ceb29cd04119515778cdddc0737a33784153ecc669705faccd9c4384604b1646f022bab7760efe42aaad117acda07b84d0c977b1ea19973c8bb8158cd2ffef2"}

I tried in a few ways, but without a chance :(

Best Answer


  • reverse1987reverse1987 Member ✭✭

    Thanks for help :) All works fine. But I still have a question, how to get to more in-depth data. I mean, of course, a user np, which has, for example, info such as first and last name. I tried user.surname but it does not work.

Sign In or Register to comment.