Unable to upload file to specific SharePoint drive,

I am trying to upload a file to SharePoint drive using graph API. I am doing OAuth using the below-mentioned link:

GET https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/authorize?client_id={CLIENT_ID}&scope=offline_access myfiles.write&response_type=code&redirect_uri=http://localhost:3000/sharepoint/integrate

After the authentication flow, I am getting both access token and refresh token. Using the access token I am able to fetch the drive list by calling the below-mentioned REST API endpoint:

GET https://graph.microsoft.com/v1.0/sites/root/drives

Headers:
Authorization: bearer {ACCESS_TOKEN}

I am also able to get the list of items present inside a specific drive by calling the below-mentioned REST API endpoint:

GET https://graph.microsoft.com/v1.0/sites/root/drives/{DRIVE_ID}/root/children/

Headers:
Authorization: bearer {ACCESS_TOKEN}

But when I am trying to upload a file to SharePoint drive using the below-mentioned REST API endpoint:

POST https://graph.microsoft.com/v1.0/sites/root/drives/{DRIVE_ID}/root/{FILE_NAME}:/content

Headers:
Authorization: bearer {ACCESS_TOKEN}
Content-Type: application/json;odata=verbose
Content-Length: FILE_SIZE

Data:
File Buffer

I am getting an error from the SharePoint API stating:

{
"error": {
    "code": "BadRequest",
    "message": "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.",
    "innerError": {
        "date": "2021-07-26T12:27:31",
        "request-id": "d54e4e48-738b-4a5c-9499-7e8c6f35ced1",
        "client-request-id": "d54e4e48-738b-4a5c-9499-7e8c6f35ced1"
    }
}
}

Can someone tell me what I am doing wrong here. I am unable to figure it out, been stuck on it for a long time.

My code is in Node.JS, any help related to this would be appreciated.

Thank you in advance.

menu – How to fix SharePoint Online sidebar navigation?

I am looking an issue in SharePoint Online site. Here menus are not getting collapses while I am clicking on other 1-Level menus.
enter image description here

In the above image first I click on the Pages menu to see the submenus inside this. After that I clicked on the Inspections menu to see its sub-menus, on the same time Pages sub-menus hierarchy is not get collapsed. Can anyone please advise what is the way here how menus will get open/ close hierarchy? Currently this is menus are getting collapse if I am clinking on the upward caret icon.

Excel is reference by the Sharepoint Site name instead of Site URL

Recently migrated files into SharePoint Online via ShareGate tool.

There is an excel, which has many formula referencing to different excels. All hosted in same site (but different libraries) in SharePoint online.

The formula is only working if we reference by site name instead of Site collection URL.

Working: ='https://XXXXXXXX.sharepoint.com/SiteName/Shared Documents/(test.xlsx)Sheet1'!$C$6

Not Working: ='https://XXXXXXXX.sharepoint.com/sites/System-portal/Shared Documents/(test.xlsx)Sheet1'!$C$6

where as in other SharePoint site it is working with only complete direct URL but not with Site name.

When I am trying to get the access the site via site name it showing 404 error in browser.

does any body have any Idea, how Excel is reaching to this site even with the wrong reference ?

SharePoint Page CSS Updated but Not Showing On Page

I needed to change the position of an element on my site page css. The folder that contains the css is located in the Site Assets. I changed it and reuploaded it to the SiteAssets, and when I open the file to check it it shows that I have changed it. Now when I load the page(s) where the issue needed to be fixed, it is still showing position: absolute; instead of position: relative;.

Any idea why my changes aren’t updating on the actual page?

Yammer tenant tenant Migration – SharePoint Stack Exchange


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




How to return user email from a custom column “Owner” to an XML from sharepoint online list using CSOM?

How to return user email from a custom column “Owner” to an XML from sharepoint online list using CSOM?
This works but bug exists as it sends Microsoft.SharePoint.Client.FieldUserValue() instead of sending user name /email. Please help with this bug

string xmlFile = @"c:tempexport.xml";
Web web = clientContext.Web;
                    ListCollection listColl = web.Lists;
                    List list = clientContext.Web.Lists.GetByTitle("Site Pages");
                    clientContext.Load(list);
                    FieldCollection listFields = list.Fields;
                    clientContext.Load(listFields);
                    clientContext.Load(listColl);
                    clientContext.ExecuteQuery();

                    ListItemCollection listItems = list.GetItems(CamlQuery.CreateAllItemsQuery());
                    clientContext.Load(listItems);
                    clientContext.ExecuteQuery();

                    XmlDocument doc = new XmlDocument();
                    XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "ISO-8859-1", null);
                    doc.AppendChild(declaration);
                    XmlElement root = doc.CreateElement("SitePages"); //CREATES FIRST ROOT NODE
                    

                    foreach (ListItem item in listItems)
                    {

                       


                        ListItem LItem = listItems.GetById(item.Id);
                        XmlElement elem = doc.CreateElement("List"); //CREATES CHILD NODE
                        

                        elem.SetAttribute("DateLastReviewed", Convert.ToString(item("DateLastReviewed")));
                        elem.SetAttribute("NextReviewDate", Convert.ToString(item("NextReviewDate")));
                        elem.SetAttribute("ContentOwner", Convert.ToString(item("Owner")));                   // bug exists as it sends Microsoft.SharePoint.Client.FieldUserValue() instead of sending user name /email
                        elem.SetAttribute("ContentNumber", Convert.ToString(item("ContentNumber")));                       
                        elem.SetAttribute("ID", Convert.ToString(item.Id));
                        root.AppendChild(elem);

                    }
                    doc.AppendChild(root);
                    doc.Save(xmlFile);
                    Console.WriteLine(" XML file is successfully generated");
                    Console.ReadKey();
                }

sharepoint online – Graph DriveItem returned WebUrl format different for .txt and .docx

I am currently using a delta query to retrieve drive items for my drive e.g.

var delta = await client
                .Sites("siteId")
                .Drives("driveId")
                .Root.Delta()
                .Request()
                .GetAsync();

This is returning as expected, my question is to do with the WebUrl property that is returned. For .txt files it will return the absolute URL e.g.
https://tenant.sharepoint.com/doclibrary/file.txt but for a .docx it will return something like the following: https://tenant.sharepoint.com/_layouts/15/Doc.aspx?sourcedoc=GUID&file=file.docx&action=default&mobileredirect=true

Is there a way to force SharePoint or Graph to return the WebUrl in an absolute format so .txt and .docx paths are the same?

Or another Graph property that will allow this to be worked out (e.g. REST has a server relative URL property)?

Thanks in advance

SharePoint Spfx CDN failed to load 406 (Not Acceptable) Error

Web part is not loading, its not able to load files from public SharePoint cdn.
enter image description here

Console error:-
enter image description here

My finding on this issue :-

  1. I have checked with 3 users and one user user is getting this error.
  2. For me some times web part was not loading but on the same time it was loading in incognito mode.
  3. We have 3 web parts on the page, for one user web part 2 was not loading and on next day webpart 2 was loading and web part 3 was not loading.

sharepoint online – How to fetch only Site Pages and not page templates from Site Pages library using REST call?

I am trying to fetch only the site pages and not the page templates using REST call, but using below RESt endpoint I am getting all the site pages including page tempates. How to filter out only the site pages from site pages library so it does include page templates present in site pages library.

/_api/web/lists/getByTitle('Site Pages')/items?$select= Title,ID&$filter=Title ne null