How to get the exact URL using development tools.

Khushboo Kumari 107 Reputation points
2023-06-25T04:19:17.4166667+00:00

Hi,

I want to create a folder and store data in this location using graph API. So from which folder I know the exact URL to use the post method to create folder and get the JSON as well by using developer tool.

Thanks!

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 46,366 Reputation points
    2023-06-26T06:54:46.8066667+00:00

    Hi @Khushboo Kumari

    Here is an example of the request to create a new folder in the signed-in user's OneDrive root folder.

    POST /me/drive/root/children
    Content-Type: application/json
    
    {
      "name": "New Folder",
      "folder": { },
      "@microsoft.graph.conflictBehavior": "rename"
    }
    

    After the creation is successful, the id and webURL of the newly created folder will be returned in the response body.

    1

    Or you can also get the webURL based on the id of the folder:

    https://graph.microsoft.com/v1.0/me/drive/items/{folder id}?$select=id,name,webURL
    

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


  2. Diya Ahuja 5 Reputation points
    2023-06-30T18:02:52.9666667+00:00

    To create a folder and store data in this location using the Microsoft Graph API, you can use the POST /me/drive/root/children endpoint. This endpoint allows you to create a new folder in the signed-in user's OneDrive root folder. The @microsoft.graph.conflictBehavior property used indicates that if an item already exists with the same name, the service should choose a new name for the folder while creating it.

    Example Request:

    POST /me/drive/root/children
    Content-Type: application/json
    
    {
        "name": "New Folder",
        "folder": { },
        "@microsoft.graph.conflictBehavior": "rename"
    }
    

    If successful, this method returns the newly created folder as a DriveItem resource.

    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.