Lesen meiner JSON-Antwort von einer Post-Anfrage, die ich gesendet habe

Ich habe eine Post-Request-Klasse erstellt, die ich wiederverwenden kann, um POST-Anfragen an eine externe API zu senden und die Objekte zurückzugeben, die sie mir senden (JSON):

class PostRequest
    {
        private Action<DataUpdateState> Callback;

        public PostRequest(string urlPath, string data, Action<DataUpdateState> callback)
        {
            Callback = callback;

            // form the URI
            UriBuilder fullUri = new UriBuilder(urlPath);
            fullUri.Query = data;

            // initialize a new WebRequest
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUri.Uri);
            request.Method = "POST";

            // set up the state object for the async request
            DataUpdateState dataState = new DataUpdateState();
            dataState.AsyncRequest = request;

            // start the asynchronous request
            request.BeginGetResponse(new AsyncCallback(HandleResponse),
                dataState);
        }

        private void HandleResponse(IAsyncResult asyncResult)
        {
            // get the state information
            DataUpdateState dataState = (DataUpdateState)asyncResult.AsyncState;
            HttpWebRequest dataRequest = (HttpWebRequest)dataState.AsyncRequest;

            // end the async request
            dataState.AsyncResponse = (HttpWebResponse)dataRequest.EndGetResponse(asyncResult);
            if (dataState.AsyncResponse.StatusCode.ToString() == "OK")
            {
                Callback(dataState); // THIS IS THE LINE YOU SHOULD LOOK AT :)
            }
        }
    }

    public class DataUpdateState
    {
        public HttpWebRequest AsyncRequest { get; set; }
        public HttpWebResponse AsyncResponse { get; set; }
    }
}

Die Callback-Methode ruft das datastate-Objekt ab und leitet es an diese Funktion weiter:

    public void LoadDashboard( DataUpdateState dataResponse )
    {
        Stream response = dataResponse.AsyncResponse.GetResponseStream();
        //Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
        //StreamReader readStream = new StreamReader(response, encode);
        //readStream.Close();


        Deployment.Current.Dispatcher.BeginInvoke(() => {
            App.RootFrame.Navigate(new Uri("/Interface.xaml", UriKind.RelativeOrAbsolute));
        });
    }

Ich bin mir jetzt nicht sicher, wie ich den Text dieser Antwort erhalten soll, die mir von der API gesendet wurde. Es gibt ein json-Format zurück. Ich muss es einer netten C # -Klasse zuordnen und zum Anzeigen von Inhalten auf dem Telefon verwenden können.

Ich kann kein Beispiel finden, das JSON.NET nicht verwendet (das keine Assembly für Windows Phone 8 enthält).

Dies ist der Fehler, den ich beim Installieren der HTTPClient-Klasse erhalte:

Attempting to resolve dependency 'Microsoft.Bcl (≥ 1.1.3)'.
Attempting to resolve dependency 'Microsoft.Bcl.Build (≥ 1.0.4)'.
Successfully installed 'Microsoft.Bcl.Build 1.0.10'.
Successfully installed 'Microsoft.Bcl 1.1.3'.
Successfully installed 'Microsoft.Net.Http 2.2.13'.
Successfully added 'Microsoft.Bcl.Build 1.0.10' to UnofficialPodio.
Executing script file ***\packages\Microsoft.Bcl.Build.1.0.10\tools\Install.ps1'.
This reference cannot be removed from the project because it is always referenced by the compiler.
This reference cannot be removed from the project because it is always referenced by the compiler.
This reference cannot be removed from the project because it is always referenced by the compiler.
This reference cannot be removed from the project because it is always referenced by the compiler.
Executing script file ***\packages\Microsoft.Bcl.Build.1.0.10\tools\Uninstall.ps1'.
Successfully uninstalled 'Microsoft.Bcl 1.1.3'.
Successfully uninstalled 'Microsoft.Bcl.Build 1.0.10'.
Install failed. Rolling back...
Failed to add reference to 'System.IO'.
"{
    \"access_token\": \"123803120312912j\",
    \"token_type\": \"bearer\",
    \"ref\": {
        \"type\": \"user\",
        \"id\": 123123
    },
    \"expires_in\": 28800,
    \"refresh_token\": \"234234f23f423q432f\"
}"

...

public class Auth
{

    [DataMember(Name = "access_token")]  
    public string AccessToken { get; set; }

    [DataMember(Name = "token_type")]  
    public string TokenType { get; set; }

    [DataMember(Name = "expires_in")]  
    public string ExpiresIn { get; set; }

    [DataMember(Name = "refresh_token")]  
    public string RefreshToken { get; set; }

    //[DataMember(Name = "ref")]  
    //public string Ref { get; set; }

}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage