sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

get workbook response 404 "Item not found"

Open vnStrawHat opened this issue 3 years ago • 3 comments

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

  • [ ] 💥 Internet Explorer
  • [ ] 💥 Microsoft Edge
  • [ ] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [X] other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version
  • SPFx version
  • Node.js version v14.19.3
  • etc Postman

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

vnStrawHat avatar Nov 28 '22 08:11 vnStrawHat

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

ghost avatar Nov 28 '22 08:11 ghost

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

omarelanis avatar Nov 30 '22 23:11 omarelanis

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.

balktl avatar Oct 08 '24 15:10 balktl

Thank you for taking the time to file an issue. We periodically archive older or inactive issues as part of our issue management process, which automatically closes them once they are archived.

If you’d like to understand more about why and how we handle archived (closed) issues, please see Our approach to closed issues.

We appreciate your contribution and if this is still an active issue with the latest SPFx versions, please do resubmit the details. We needed to perform a cleanup, so that we can start with a clean table with a new process. We apologize for the inconvenience this might cause.

github-actions[bot] avatar May 02 '25 15:05 github-actions[bot]