Reputation: 31
I am trying to call the gen2 rest endpoint directly and keep getting an error that I am missing a required header (MissingRequiredHeader message An HTTP header that's mandatory for this request is not specified. I fail to see what header is missing. I'm using the following code to send the request.
var client = new HttpClient();
client.BaseAddress = new Uri($"https://{account}.dfs.core.windows.net/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("api_version", "2018-11-09");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _authResult.AccessToken);
string azPath = $"{baseRawSystemPath}/{path.Replace("\\", "/")}";
byte[] bytes = Encoding.UTF8.GetBytes(content);
HttpContent body = new StringContent(content, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PutAsync(azPath, body);
if (response.IsSuccessStatusCode)
{
var responseListingJson = await response.Content.ReadAsStringAsync();
return;
}
else
{
var error = await response.Content.ReadAsStringAsync();
return;
}
Upvotes: 0
Views: 1234
Reputation: 31
Just to answer my own question... I was missing the resource=file query string parameter. That allowed the request to succeed and the file to be created.
Upvotes: 2