Hello I had a problem loading the image onto the user's wall. At first I thought that I wasn’t correctly sending POST easily, but as it turned out the problem is that I don’t get the server URI where I need to upload images. Here is the code.
WebRequest webRequest = WebRequest.Create("https://api.vk.com/method/photos.getWallUploadServer?user_id="+userId+"&access_token="+token); WebResponse webResponse = webRequest.GetResponse(); Stream stream = webResponse.GetResponseStream (); //тут я получаю URI stream.Write(arr, 1 , arr.Length); string jsonR = Encoding.UTF8.GetString(arr); var jso = (JObject)JsonConvert.DeserializeObject(jsonR); string url = jso["response"]["upload_url"].ToString(); //POST запрос var myWebClient = new WebClient(); byte[] responseArray = myWebClient.UploadFile(url, filePath); string jsonResponse = Encoding.UTF8.GetString(responseArray); var json = (JObject)JsonConvert.DeserializeObject(jsonResponse); string photo = json["response"]["photo"].ToString(); string server = json["response"]["server"].ToString(); string hash = json["response"]["hash"].ToString(); //загрузка изображения WebRequest.Create("https://api.vk.com/method/photos.saveWallPhoto.xml?aceess_token="+ token+"&server="+server+"&photo="+photo+"&hash="+hash); xmlDocument.Load (stream); string photoLoad = xmlDocument.SelectSingleNode("responce/id").InnerText; string URI = "https://api.vk.com/method/wall.post.xml?"; URI +="access_token="+ token; URI += "&owner_id="+userId; URI += "&attachments=photo"+userId+"_"+photoLoad; URI += ",note"+userId+"_"+stext; URI += "&message="+stext; WebRequest.Create(URI);