Morning,
I am trying to use https://api.real-debrid.com/ to add a torrent . When I execute my code I get Bad Request reponse. I have varified the torrent file is correct. I dont have much experience with rest apis. The docs for the api are not great. Is there anything obviously wrong with my code. Thx in advance, here is my code:
public async Task AddTorrent2(string filePath)
{
if (!File.Exists(filePath))
{
throw new FileNotFoundException("File not found", filePath);
}
var requestContent = new MultipartFormDataContent();
var fileContent = new ByteArrayContent(File.ReadAllBytes(filePath));
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-bittorrent");
// fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
requestContent.Add(fileContent, "file", Path.GetFileName(filePath));
var method = "https://api.real-debrid.com/rest/1.0/torrents/addTorrent";
var response = await this.httpClient.PutAsync(method, requestContent);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Success! Response: " + responseBody);
}
else
{
Console.WriteLine("Error: " + response.StatusCode);
}
}