I need to translate the following curl
call to a HttpClient
call:
curl:
curl -i -X GET "https://dev.wetransfer.com/v2/transfers/{transfer_id}/files/{file_id}/upload-url/{part_number}" \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key" \
-H "Authorization: Bearer jwt_token"
My attempt at using Httpclient:
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("x-api-key", My_Correct_ApiKey);
client.DefaultRequestHeaders.Add("Authorization",My_Correct_Token);
var xxx = client.GetAsync($"https://dev.wetransfer.com/v2/transfers/{response.Id}/files/{file.Id}/upload-url/{partNumber}").Result;
}
You will have to take my word that I filled in the parameters correctly. Now, the curl call works as expected and returns a Json message. The .Net code fails with a "Unsupported Media Type" response.
The curious thing is that the request does not have any Json-serialized content: all the info needed is packed into the Request Uri. (And as I understand it HttpClient
does not support content on GET calls.)
Where am I going wrong?