Sharepoint and Microsoft Graph Bad Request

I try to create a folder in Microsoft Sharepoint with Xamarin. But I only get Bad Requests.
It works, when I use the graph explorer from Microsoft Graph Explorer.

` public async void PushToAzure() {
var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", App.AuthenticationResult.AccessToken);

        var body = "{\"name\": \"New Folder\",\"folder\": { }}";
        var contents = new StringContent(body);
        contents.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json;odata=verbose");

        try {
            var postResult = await client.PostAsync("", contents);
            var result = postResult.EnsureSuccessStatusCode();
            if (result.IsSuccessStatusCode) {
                Debug.WriteLine("List item created successfully");
        } catch (Exception ex) {
            Debug.WriteLine("Unable to create list item " + ex.Message);

I used this two Tutorials:
Somebody know how to fix this?

Sign In or Register to comment.