public static string UploadPhoto(string path, string filename, string contentType, string message) { var parameters = new Dictionary<string, object>(); parameters["message"] = message; parameters["file1"] = new MediaObject { ContentType = contentType, FileName = Path.GetFileName(filename) } .SetValue(File.ReadAllBytes(path)); // Stream to save the response to var responseSaveStream = new MemoryStream(); // Prepare the request. var request = new FluentHttpRequest() .BaseUrl("https://graph.facebook.com") .ResourcePath("/me/photos") .Method("POST") .Headers(h => h.Add("User-Agent", "FluentHttp")) .QueryStrings(qs => qs.Add("access_token", AccessToken)) .Proxy(WebRequest.DefaultWebProxy) .OnResponseHeadersReceived((o, e) => e.SaveResponseIn(responseSaveStream)) .Body(body => AttachRequestBodyAndUpdateHeader(body.Request, parameters, null)); // Execute the request. Call EndRequest immediately so it behaves synchronously. var ar = request.Execute(); // seek the save stream to beginning. responseSaveStream.Seek(0, SeekOrigin.Begin); var responseResult = FluentHttpRequest.ToString(responseSaveStream); // Convert to json var json = (IDictionary<string, object>)SimpleJson.SimpleJson.DeserializeObject(responseResult); if (ar.Exception != null) { throw ar.Exception; } // Print the response Console.WriteLine("Upload photo: "); Console.WriteLine(responseResult); if (ar.InnerException != null) { throw ar.InnerException; } return (string)json["id"]; }