We have been trying to add a document to a list item using Graph API but are being thrown a 400 error :( We have the access token and can query the list in question without any problem. Below is the code we are using to try to add the document to the list
string addItemJsonString = "{\"fields\":{\"Title\":\"Dec Word file\"}}";
string requestUrl = "https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/mySite:/lists/My Library/items";
HttpClient client = new HttpClient();
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, requestUrl);
message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
message.Content = new StringContent(addItemJsonString, Encoding.UTF8, "application/json"); //set the body for the request
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
HttpResponseMessage response = await client.SendAsync(message);
if (response.IsSuccessStatusCode)
{
responseString = await response.Content.ReadAsStringAsync();
}
else
responseString = "Error in response";
Any idea of where we are losing it?