I’m attempting to transfer files from a file system to Azure object storage, but I’m encountering a 400 Bad Request error. According to the Orthanc log file, the issue is related to the “Priority” parameter, which is expected to be an integer. However, I have confirmed that it is indeed an integer value. Any assistance would be greatly appreciated.
Below is my C# code.
public class MoveStorageRequest
{
public string Resources { get; set; }
public string TargetStorage { get; set; }
public bool Asynchronous { get; set; }
public int Priority { get; set; }
}
private async void btnRun_Click(object sender, EventArgs e)
{
string apiUrl = “http://localhost:8042/move-storage”;
var request = new MoveStorageRequest()
{
Resources = new string[] { "5f682793-582e82ce-686747c8-51b998dc-1f86a55b" },
TargetStorage = "object-storage", // I tries "file-system" as well to test the program
Asynchronous = true,
Priority = 0
};
await MoveStudyToBlob(apiUrl, request);
}
static async Task MoveStudyToBlob(string apiUrl, MoveStorageRequest request)
{
var json = JsonSerializer.Serialize(request);
using (var client = new HttpClient())
{
var requestMessage = new HttpRequestMessage(HttpMethod.Post, apiUrl);
requestMessage.Content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.SendAsync(requestMessage);
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Storage moved successfully.");
}
else
{
Console.WriteLine("Error moving storage: " + response.StatusCode);
}
}
}