Skip to content

REST API inconsistency: getFolderByServerRelativePath & getFileByServerRelativePath #7437

@salascz

Description

@salascz

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
  • other (enter in the "Additional environment details" area below)

Additional environment details

No response

Issue description

Hello,
I am building a solution generating folders and files structure including a validation if such a name exists in the parent folder.

I am using the /_api/web/getFolderByServerRelativePath call for folders validation. There is a way, how to check if folder exist without an 404 error returned (by selecting the Exists property:
GET <site>/_api/web/getFolderByServerRelativePath(decodedUrl='<folder_url>')?$select=Exists
(the same call without selected Exists property would return error)

However the similar approach does not work for files - it returns an error all the time. (tested with getFolderByServerRelativeUrl and getFileByServerRelativeUrl with same results)

  • Is there another way, how to check if file exists without an error returned from the call?
  • Do anyone know, why are those calls inconsistent?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:csom/rest/apiCategory: SharePoint Client Side Object Model SDK / REST APItype:archive-old-issueIssues which are closed as tool old for active work

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions