Microsoft Graph - Add Worksheet responds with Invalid Request

Andreas Lau 20 Reputation points
2023-12-11T09:20:27.6466667+00:00

Hello,

I'm trying to add a Worksheet via PHP and Microsoft Graph. Sadly, I get an "Invalid Request" as a Reponse. Can anyone tell me what I'm doing wrong? Thanks in advance. Code as follows:

$requestBody = new AddPostRequestBody();
$requestBody->setName('TestNameForWorksheet');   
$result = $graphServiceClient
            ->drives()
            ->byDriveId($driveId)
            ->items()
            ->byDriveItemId($worksheetId)
            ->workbook()
            ->worksheets()
            ->add()
            ->post($requestBody)
            ->wait();
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,049 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,205 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 38,956 Reputation points Microsoft Vendor
    2023-12-12T02:04:58.08+00:00

    Hi @Andreas Lau,

    I'm glad to hear you solve the problem ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.

    By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:

    [Microsoft Graph - Add Worksheet responds with Invalid Request]

    Issue Symptom:

    Get an "Invalid Request" as a Reponse when trying to add a Worksheet via PHP and Microsoft Graph

    Solution:

    Check the id and found using the wrong id. Reacquire the correct id fix the issue


    You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Andreas Lau 20 Reputation points
    2023-12-11T09:26:41.8433333+00:00

    Found the problem, it was me and the wrong Id.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.