I've stumbled upon issue where I need to create a link in navigation from root site which points to site collections.

POST Request URL: https://contoso.sharepoint.com/_api/web/navigation/TopNavigationBar


    "__metadata": {
        "type": "SP.NavigationNode"
    "Url": "https://contoso.sharepoint.com/sites/nonexisting",
    "Title": "Non existing"

Error response:

    "odata.error": {
        "code": "-2130247147, Microsoft.SharePoint.SPException",
        "message": {
            "lang": "en-US",
            "value": "Cannot open \"/sites/nonexisting\": no such file or folder."

Tried to create it manually - works fine. Got new link by REST API to check properties:

                "AudienceIds": null,
                "CurrentLCID": 1033,
                "Id": 7617,
                "IsDocLib": true,
                "IsExternal": true,
                "IsVisible": true,
                "ListTemplateType": 0,
                "Title": "Nonexisting",
                "Url": "/sites/nonexisting"

Nothing out of ordinary.

I'm wondering, is it even possible to create such links with REST API?

  • I don't quite understand the question. Could you just hardcode the response when site not existing?
    – Mark L
    Nov 4, 2021 at 6:24
  • Hello @MarkL You can see the response under "Error response". nonexisting is just some URL part, that doesn't exist in SharePoint tenant Nov 4, 2021 at 8:42

1 Answer 1


There is a solution to this: https://github.com/pnp/pnpcore/discussions/610

In general - you need to create a navigation node that does not point to non-existing URL in your site collection, and then update URL with PATCH request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.