private void getList(string restApiPath, Dictionary<string, string> output, Type type, string label) { webRequest = (HttpWebRequest)WebRequest.Create(restApiPath); path = restApiPath; labelValue = label; webRequest.Method = "POST"; webRequest.ContentType = Globals.POST_CONTENT_TYPE; webRequest.Headers["st"] = MPFPConstants.serviceType; webRequest.BeginGetRequestStream(result => { HttpWebRequest request = (HttpWebRequest)result.AsyncState; // End the stream request operation Stream postStream = request.EndGetRequestStream(result); // Create the post data string reqData = Utils.getStringFromList(output); string encode = RESTApi.encodeForTokenRequest(reqData); byte[] byteArray = Encoding.UTF8.GetBytes(encode); postStream.Write(byteArray, 0, byteArray.Length); postStream.Close(); request.BeginGetResponse(new AsyncCallback(GetResponseCallbackForSpecificConditions), request); }, webRequest); } private void GetResponseCallbackForSpecificConditions(IAsyncResult ar) { //code }