SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.25k stars 1.01k forks source link

get workbook response 404 "Item not found" #8617

Open vnStrawHat opened 2 years ago

vnStrawHat commented 2 years ago

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

SharePoint REST API

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested

Additional environment details

Issue description

Sending API request to get workbook of excel file in Sharepoint Online return 404 "Item not found". API:

https://my-compary.sharepoint.com/_api/v2.0/drives/b!NkttCrd_dUWKmwoOvUUtX3yAAg8MIa1LuGTztRezWUOd_lXA-m1xxxxxxxxx/items/01HEO2IVZTTVTHWBWNMFCLN5TRBWxxxxxx/workbook

Response:

{
    "error": {
        "code": "itemNotFound",
        "message": "Item not found"
    }
}

But call API to item with ID 01HEO2IVZTTVTHWBWNMFCLN5TRBWxxxxxx still response data: API:

https://my-compary.sharepoint.com/_api/v2.0/drives/b!NkttCrd_dUWKmwoOvUUtX3yAAg8MIa1LuGTztRezWUOd_lXA-m1xxxxxxxxx/items/01HEO2IVZTTVTHWBWNMFCLN5TRBWxxxxxx/

Response:

{
    "@odata.context": "https://my-compary.sharepoint.com/_api/v2.0/$metadata#items/$entity",
    "@content.downloadUrl": "...snip.....",
    ....snip...
}

I try to use Graph API to call and able to get workbook data: Graph API:

https://graph.microsoft.com/v1.0/drives/b!NkttCrd_dUWKmwoOvUUtX3yAAg8MIa1LuGTztRezWUOd_lXA-m1xxxxxxxxx/items/01HEO2IVZTTVTHWBWNMFCLN5TRBWxxxxxx/workbook

Response:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21NkttCrd_dUWKmwoOvUUtX3yAAg8MIa1LuGTztRezWUOd_lXA-m1xxxxxxxxx')/items('01HEO2IVZTTVTHWBWNMFCLN5TRBWxxxxxx')/workbook/$entity",
    "@odata.id": "/drives('b%21NkttCrd_dUWKmwoOvUUtX3yAAg8MIa1LuGTztRezWUOd_lXA-m1xxxxxxxxx')/items('01HEO2IVZTTVTHWBWNMFCLN5TRBWxxxxxx')/workbook/"
}

Token use to call sharepoint API generated by using Sharepoint App-Only with FullControl permissions Call Graph API by using Graph Explorer with user have permission site Owner

ghost commented 2 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

omarelanis commented 2 years ago

Can you please explain what you are trying to achieve here, are you trying to get a raw stream of the data in the file?

The link you provided includes "workbook" at the end (https://my-compary.sharepoint.com/_api/v2.0/drives/b!NkttCrd_dUWKmwoOvUUtX3yAAg8MIa1LuGTztRezWUOd_lXA-m1xxxxxxxxx/items/01HEO2IVZTTVTHWBWNMFCLN5TRBWxxxxxx/workbook) can you explain why?

Does the link direct like this, return the response as detailed in the API docs (https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get?view=odsp-graph-online)?

https://my-compary.sharepoint.com/_api/v2.0/drives/b!NkttCrd_dUWKmwoOvUUtX3yAAg8MIa1LuGTztRezWUOd_lXA-m1xxxxxxxxx/items/01HEO2IVZTTVTHWBWNMFCLN5TRBWxxxxxx

I could be wrong, but I think you need to read the documentation on the /content endpoint:

GET /drives/{drive-id}/items/{item-id}/content

balktl commented 1 month ago

Could this issue be re-triaged? The workbook API is a valid graph endpoint for the ability to update Excel files within SharePoint Online/OneDrive. https://learn.microsoft.com/en-us/graph/api/resources/excel?view=graph-rest-1.0

So, this is useful when doing a bulk conversion of flat JSON data Excel in a quick and non-iterative way via Power Automate's SharePoint Rest API event. The content endpoint yields a stream object and that isn't suitable for these kinds of interactions.