0

I need to fetch a simple document template file (.doc) from google docs (or drive), then fill in the missing details and save the document as new file into the cloud.

Could someone advise on how to achieve this using the Google Docs API so this could be done within bespoke environment?

thanks in advance

1
  • Hello, did your issue get solved? Remember that if you want to mark your question as solved you can accept whatever answer provided a solution to your problem. If that's not the case and your issue is not solved, please consider explaining why that's not the case so that this community can help you. Commented Nov 19, 2019 at 15:50

1 Answer 1

0

If I understand you correctly, you want to programmatically:

  • Retrieve a document from Drive.
  • Edit this document while keeping the original one unmodified.
  • Save this new document.

You have to follow these steps:

  • Use Files.copy from Drive API to copy the file you want to edit. To achieve this, you have to provide the id of the original file as a request parameter. As a response you will get a File resource corresponding to the copy you created. Retrieve the file id from this response.
  • Update this new file using batchUpdate from Docs API. For that you will need to (1) provide the file id you retrieved in the previous step as a parameter and (2) provide the changes you want to make using the requests parameter (an array of all the changes you want to make) in the request body (check the links I attach to know exactly how should your requests parameter be like - I would like to be more specific here, but I don't know how exactly do you want to modify the document).

Obviously, there is no need to save the modified document, this is done automatically when the file is modified.

I hope this is of any help to you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.