K
K
killman2022-03-22 17:41:22
Windows
killman, 2022-03-22 17:41:22

Error "VkNet.Exception.ParameterMissingOrInvalidException visual studio windows forms c# VK API. How to fix?

created a program that should take a photo from a computer and upload it to the VKontakte community. But when compiling, it gives an error VkNet.Exception.ParameterMissingOrInvalidException: "One of the parameters specified was missing or invalid: invalid message param"
Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Net;
using vknet;
using VkNet.Model;
using System.Threading;
using xNet;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using VkNet.Model.Attachments;

namespace Vkner_test
{

public partial class Form1 : Form
{
public string post_ID;
WebClient client = new WebClient();
public VkApi api = new VkApi();
long owner_id = -211976873;
string message = "Hello everyone, this is a VK API test";
ulong appID = 8110264;
stringlogin1;
string password;
authorization auth = new authorization();

List attachments = new List();

OpenFileDialog openFileDialog = new OpenFileDialog();
uri file;

public Form1()
{

InitializeComponent();


}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{



attachments.Add(new Photo
{

Url = file,

});





api.Wall.Post(new VkNet.Model.RequestParams.WallPostParams
{
OwnerId = owner_id,
FriendsOnly = false,
FromGroup = true,
// Message = message,


Attachments = attachments,

});


}

private void button2_Click(object sender, EventArgs e)
{
//auth.ShowDialog();
//error.Text = api.Token;


try
{
api.Authorize(new ApiAuthParams
{
AccessToken = *******
});

error.Text = "";
}
catch (VkNet.Exception.VkAuthorizationException)
{

error.Text = "Invalid username or password";

}

}

private void button3_Click(object sender, EventArgs e)
{
var openfile = openFileDialog.ShowDialog();

if (openfile == DialogResult.OK)
{
file = new Uri(openFileDialog.FileName);
}
}
}
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question