How add the POST data in the json request body of REST services Using C#

private void CreateNewTasklist(string TasklistTitleValue)
        AuthenticationProcess objUri = new AuthenticationProcess();

        if (string.IsNullOrEmpty(TasklistTitleValue))
            MessageBox.Show("Please Enter the Tasklist Title.");
            //Read the Token result in Isolated storage.
            string TokenResult = TasklistManager.ReadTokenResult();
            var Token = Auth.ParseAuthJsonString(TokenResult);

            var request = new RestRequest(objUri.CreateTasklist, Method.POST);
            request.AddHeader("content-type", "application/json");

            RestClient client = new RestClient("");
            client.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(Token.access_token);
            client.ExecuteAsync<TasklistManager>(request, TaskListsLoaded);

Here I get string TasklistTitleValue value .. i want to POST it. How to add it to request body as content-type is application/json.


You could do this:

var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://url");
httpWebRequest.ContentType = "text/json";
httpWebRequest.Method = "POST";

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
string json = "{\"user\":\"test\"," +


var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
    var result = streamReader.ReadToEnd();

or you can use this:

Need Your Help

How to call a file in /data/data with MediaPlayer

java android media-player midi

I want Android to play a song in /data/data/com.example.myapp/ called test3.mid