How to create new Quip spreadsheet using API

594 views Asked by At

I wanted to programmatically create a new Quip spreadsheet with headers and content pulled from another database

new_ss = client.new_document(title="New
Spreadsheet",member_ids=[user["private_folder_id"]])

But this only creates a new doc not a spreadsheet. I tried to follow this Create Quip Spreadsheet but "type" is an unknown keyword. How can I do that?

jso = client.new_document("", title="My Spreadsheet", type="spreadsheet")

1

There are 1 answers

0
srgsanky On

To use quip client, we copy the quip.py file from https://github.com/quip/quip-api/blob/master/python/quip.py to our project.

Since new_document didn't have the advertised type argument, I ended up editing the copy of quip.py to include the additional argument. Here is the diff

--- a/quip.py
+++ b/quip.py
@@ -300,7 +300,7 @@ class QuipClient(object):
             "member_ids": ",".join(member_ids),
         })
 
-    def new_document(self, content, format="html", title=None, member_ids=[]):
+    def new_document(self, content, format="html", title=None, member_ids=[], doc_type="document"):
         """Creates a new document from the given content.
 
         To create a document in a folder, include the folder ID in the list
@@ -310,16 +310,18 @@ class QuipClient(object):
             user = client.get_authenticated_user()
             client.new_document(..., member_ids=[user["archive_folder_id"]])
 
+        doc_type is one of document or spreadsheet.
         """
         return self._fetch_json("threads/new-document", post_data={
             "content": content,
             "format": format,
             "title": title,
             "member_ids": ",".join(member_ids),
+            "type": doc_type
         })
 
     def copy_document(self, thread_id, folder_ids=None, member_ids=None,