skip to Main Content

I created a flow that would create a new page from items inputted into a SharePoint list.

The first step is supposed to copy a template file and post it as a new page using the List Item’s title name.

My inputs are as follows:

{
    "host": {
        "connectionReferenceName": "shared_sharepointonline",
        "operationId": "HttpRequest"
    },
    "parameters": {
        "dataset": "https://myTenant.sharepoint.com/sites/KSDTestSite",
        "parameters/method": "POST",
        "parameters/uri": "_api/web/GetFileByServerRelativePath(‘/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx’)/copyTo(‘/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
        "parameters/headers": {
            "Accept": "application/json;odata=verbose",
            "content-type": "application/json;odata=verbose"
        }
    }
}

and the Outputs:

{
    "statusCode": 400,
    "headers": {
        "Pragma": "no-cache",
        "Cache-Control": "no-store, no-cache",
        "Set-Cookie": "ARRAffinity=fa5ce4b13622b0d3617b4398e823c470b20f49c8905d33671c1e72b454b4c01b;Path=/;HttpOnly;Secure;Domain=sharepointonline-ncus.azconn-ncus-001.p.azurewebsites.net,ARRAffinitySameSite=fa5ce4b13622b0d3617b4398e823c470b20f49c8905d33671c1e72b454b4c01b;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ncus.azconn-ncus-001.p.azurewebsites.net",
        "x-ms-request-id": "86e9b9a0-403e-3000-ac9a-13008bc3168f",
        "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
        "X-Content-Type-Options": "nosniff",
        "X-Frame-Options": "DENY",
        "Timing-Allow-Origin": "*",
        "x-ms-apihub-cached-response": "true",
        "x-ms-apihub-obo": "false",
        "Date": "Mon, 05 Jun 2023 16:37:17 GMT",
        "Content-Length": "750",
        "Content-Type": "application/json",
        "Expires": "-1"
    },
    "body": {
        "status": 400,
        "message": "The expression "web/GetFileByServerRelativePath(‘/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx’)/copyTo(‘/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')" is not valid.rnclientRequestId: 5b37d689-d8b9-439f-af4f-2005d6b07e0drnserviceRequestId: 86e9b9a0-403e-3000-ac9a-13008bc3168f",
        "source": "https://myTenant.sharepoint.com/sites/KSDTestSite/_api/web/GetFileByServerRelativePath(%E2%80%98/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx%E2%80%99)/copyTo(%E2%80%98/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
        "errors": [
            "-1",
            "Microsoft.SharePoint.Client.InvalidClientQueryException"
        ]
    }
}

I keep running into this "Microsoft.SharePoint.Client.InvalidClientQueryException" error, which I’ve seen it could be a permissions issue? But its a dev environment and there are really no permissions to speak of. Anyways, if anyone has any idea, it would be greatly appreciated.

HTTP Request to SharePoint

Full Error Page Full Error Page

2

Answers


  1. Chosen as BEST ANSWER

    Turns out the issue was, yet again, another instance of improper characters in my code.

    (Specifically speaking about the apostrophes in my code)

    Once I deleted the copied apostrophes and replaced them with the approved "tic marks", I was able to move onto the next error. #progress!

    Refer to the images for examples:

    JSON does not approve! JSON does not approve!

    JSON approved! JSON approved!


  2. As you find by yourself, there was an issue with quotes in the URI:

    was used instead of

    Correct syntax is:

    {
        "host": {
            "connectionReferenceName": "shared_sharepointonline",
            "operationId": "HttpRequest"
        },
        "parameters": {
            "dataset": "https://your-tenant.sharepoint.com/sites/KSDTestSite",
            "parameters/method": "POST",
            "parameters/uri": "_api/web/GetFileByServerRelativePath('/sites/KSDTestSite/SitePages/Templates/KSD-Template.aspx')/copyTo('/sites/KSDTestSite/SitePages/Microsoft_Security_Update_and_EOL_Notification.aspx')",
            "parameters/headers": {
                "Accept": "application/json;odata=verbose",
                "content-type": "application/json;odata=verbose"
            }
        }
    }
    

    For security purpose, I remove your tenant root URL.
    Feel free to edit your question and blur your screenshot as well.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search