1 year ago
#368249
HAAAAAH
C# How to get sent file's link HttpClient
Hello i have this code:
using (WebClient client = new WebClient())
{
string TargetFileName = @"C:\test.txt";
var resStr = client.UploadFile(@"https://discord.com/api/webhooks/959919400243326976/uGiJbuiddUbEGovMgKtx2Z-byUX7jvhCcqgs5-IBYq1pAIrKlpnyVvjrMicJjS9tC_-a", TargetFileName);
var jObjResult = JObject.Parse(Encoding.UTF8.GetString(resStr));
var linkToFile = jObjResult["data"]["file"]["url"]["full"].ToString();
}
It works well but i need get sent file's (test.txt) link and write it inside Console like
Console.Write("File is sent to webhook! Link: " + <test.txt's link>);
But im taking that error:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
How to fix it?
c#
webhooks
webclient
0 Answers
Your Answer