Loading

Edit Doc Section via API

Veröffentlichungsdatum: Feb 11, 2024
Lösung

Step 1
Create a new Quip document with a table. In one of the cells, place the word “Before”.

Step 2
Examine the URL of your new document. The document ID (aka “Thread ID”) is in the URL. In this example, the Thread ID is bseaAILH8Pt9.

Next up, we’ll use Quip’s Automation API to query the thread.

Step 3
To make Automation API calls, you’ll need to generate an access token that provides API access to your own, personal Quip account. Do this by visiting https://quip.com/dev/token.

Step 4
Click Get Personal Access Token to generate a token. Copy this token – you’ll need it in step 6. Be sure to never share this token with anyone – not even a Salesforce or Quip representative!

Step 5
Download Postman. In Postman, click New and select Request. If prompted, you can name the request “Get a thread”.

Step 6

  • At the top, next to GET, paste in the URL https://platform.quip.com/1/threads/ID - but replace ID with your document’s thread ID from step 2.
  • In the Authorization tab, set Type to OAuth 2.0.
  • Set Add Authorization data to to “Request Headers”.
  • For Access Token, paste in your token from step 4.


Step 7
Click the blue button Send to submit your API query. Quip’s response will show below.

Take a moment to scroll down and view the full response from Quip.

You’ll notice a lot of data is included, such as the author’s ID, the type of document (document vs sheet), and various timestamps.

You’ll also notice the full HTML body of the doc is included too.


Step 8
Click the magnifying glass icon and search for the word “Before”. This is a specific table cell in your doc. Note the section ID of the cell. In the example on the right, the section ID is s:TbUACAI6LgB_TbUACAWHjs6. You’ll need this later in step 16.
 


Intermission

Let’s recap. You just used Automation API to retrieve a document (called “thread”).

Now that you know your document’s thread ID and the section ID of some text, you can use a 2nd Quip API query to change this text from “Before” to “After”. While it’s possible to make this edit with the Automation API , we’ll use the Admin API to help you understand the difference between the two APIs.

While the Automation API leverages a token tied to your Quip user to make API calls (and is limited to doing things your user can do), the Admin API uses an API key created by an admin of your Quip site. As such, you can use the Admin API to access content your individual Quip user may not normally have access to. The Admin API also includes additional endpoints that the Automation API doesn’t have, such as Delete Message.
 



Step 9
Have an admin of your Quip site create an API key for you by accessing the Admin Console of Quip, then going to Settings → Integrations → New API Key. For your testing key, you can enable all permitted scopes.

After creating the key, click View next to the key to see your Client ID and Client Secret. You’ll need this in step 14.


Step 10
Your Quip admin will also need to go to Settings → Site Settings. Note the Company ID at the top of this page as you’ll need it in step 16.


Step 11
Scroll down on this same page to the Admin API Users section and click Grant Access. Follow the steps to grant Admin API access to your Quip user.

Next we’ll configure Postman to make your Admin API call.


Step 12
In Postman, click New and select Request. If prompted, you can name the request “Admin: Edit a thread”.


Step 13
At the top, change GET to POST. Then, paste in the URL https://platform.quip.com/1/admin/threads/edit-document.


Step 14
In the Authorization tab, set Type to OAuth 2.0. Set Add authorization data to to “Request Headers”. On the right, expand Configure New Token and fill it out:

  • Token Name: Postman
  • Grant Type: Authorization Code
  • Callback URL: (Check the checkbox Authorize using browser)
  • Auth URL: https://platform.quip.com/1/oauth/login
  • Access Token URL: https://platform.quip.com/1/oauth/access_token
  • Client ID: (Paste this in from Step 9)
  • Client Secret: (Paste this in from Step 9)
  • Scope: (Leave blank)
  • State: (Leave blank)
  • Client Authorization: Send credentials in body

Step 15
Click Get New Access Token. You’ll be redirected to your web browser to authenticate with Quip.

Eventually, you should land on a Manage Access Tokens screen. From here, click the Use Token button.

Step 16
Click into the Body sub-tab and input the following fields to build your API request.

Be sure to use your own company_id (from step 10), thread_id (from step 2), and section_id (from step 8).


Step 17
Click the blue button Send to submit your API query. Quip’s response will show below.

If all of your inputs are correct, your document should reflect the change. If it does, congratulations! If you encountered any issues at all, please contact Quip support and we’ll help you through the finish line.

 
 
 
Nummer des Knowledge-Artikels

000392356

 
Laden
Salesforce Help | Article