Reputation: 41
I'm using this library as a NuGet package(InstaSharper) for instagram bot program: https://github.com/a-legotin/InstaSharper
And in the InsertImage();
function, which is meant for uploading a photo to instagram page, while parsing, the program runs into a problem and console reuturns:
Loged in! Unable to upload photo: Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
I tried using different paths and image types, but the same thing happens.
What could be the problem and how to fix it?
These are main functions:
static void Main(string[] args)
{
user = new UserSessionData();
user.UserName = username;
user.Password = password;
Login();
Console.Read();
}
public static async void Login()
{
api = InstaApiBuilder.CreateBuilder().SetUser(user).UseLogger(new DebugLogger(LogLevel.Exceptions)).SetRequestDelay(RequestDelay.FromSeconds(1, 3)).Build();
var loginRequest = await api.LoginAsync();
if (loginRequest.Succeeded)
{
Console.WriteLine("Loged in!");
InsertImage(@"C:\test.jpg", "Testing");
}
else Console.WriteLine("Unable to log in: " + loginRequest.Info.Message);
}
public static async void InsertImage(string _path, string _caption)
{
var mediaImage = new InstaImage
{
Height = 1080,
Width = 1080,
URI = new Uri(Path.GetFullPath(_path), UriKind.Absolute).LocalPath
};
var result = await api.UploadPhotoAsync(mediaImage, _caption);
if (result.Succeeded == true) Console.WriteLine($"Media created: {result.Value.Pk}, {result.Value.Caption}");
else Console.WriteLine($"Unable to upload photo: {result.Info.Message}");
}
Upvotes: 4
Views: 708
Reputation: 23
It seems InstaSharper Nuget Package is not updated, I've downloaded it from Github and use it in my project, it worked for me
Hope this helps
Upvotes: 0