Handle a New URL

When a user clicks the "New" button and selects an app in the Drive UI, Drive redirects the user to that app's New URL defined when you Configure a Drive integration.

As mentioned in Configure a Drive UI integration, your app receives a default set of template variables within a state parameter. The default state information for a New URL is:

{
  "action":"create",
  "folderId":"0ADK06pfg",
  "userId":"103354693083460731603"
}

To handle this information:

  1. Detect the create value in the state parameter to verify that this is a request to create a new file.

  2. Use the files.insert method to create the file using the folderId and userId values.

The state parameter is URL-encoded, so your app must handle the escape characters and parse it as JSON.

Next steps

You might want to create a shortcut instead of a file stored in Drive. For further information, refer to Create a shortcut to a file.