What is the Best Way to Transfer a Google Doc into Wordpress?

This topic was automatically generated from Slack. You can find the original thread here.

I need to take a Google Doc and put it in Wordpress.

What would be the best way to do this?

To achieve this, you can create a Pipedream workflow with the following steps: 1. Set up a trigger for the workflow, such as an HTTP trigger, a Scheduler, or a Google Drive event (e.g., when a new Google Doc is created or updated). 2. Use the Google Drive API to read the content of the Google Doc. You can use the @pipedream/platform axios package to make the API request. Make sure to use the OAuth access token from your Google app, like this: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google: { type: "app", app: "google", }, }, async run({ steps, $ }) { // Replace DOC_ID with the actual Google Doc ID const docId = "DOC_ID"; const response = await axios($, { url: `https://www.googleapis.com/drive/v3/files/${docId}/export`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, params: { mimeType: "text/html", }, }); const googleDocContent = response.data; // Continue with the next step }, }); 3. Use the Wordpress API to create or update a post with the content from the Google Doc. You’ll need to use the @pipedream/platform axios package again to make the API request, and make sure to use the OAuth access token from your Wordpress app. 4. Combine these steps in a Pipedream workflow and customize it according to your needs. If you need further assistance or have any questions, feel free to ask.

Please update this code so that I can dynamically put the DOC ID in a field.

Sure, I’ve updated the code to include a docId prop, which allows you to dynamically input the Google Doc ID: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google: { type: "app", app: "google", }, docId: { type: "string", label: "Google Doc ID", }, }, async run({ steps, $ }) { const response = await axios($, { url: `https://www.googleapis.com/drive/v3/files/${this.docId}/export`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, params: { mimeType: "text/html", }, }); const googleDocContent = response.data; // Continue with the next step }, }); Now, you can input the Google Doc ID in the docId field when you use this component in your workflow.

This code needs to be updated because Google needs to know what Drive it’s looking for the DOC in.

I apologize for the confusion earlier. To specify the Google Drive you want to search for the Google Doc, you can use the driveId parameter in the Google Drive API request. First, you’ll need to obtain the driveId of the desired Google Drive. You can find it in the Google Drive URL or use the Google Drive API to list your drives and get the driveId. Here’s the updated code with the driveId parameter: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google: { type: "app", app: "google", }, docId: { type: "string", label: "Google Doc ID", }, driveId: { type: "string", label: "Google Drive ID", }, }, async run({ steps, $ }) { const response = await axios($, { url: `https://www.googleapis.com/drive/v3/files/${this.docId}/export`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, params: { mimeType: "text/html", driveId: this.driveId, }, }); const googleDocContent = response.data; // Continue with the next step }, }); Now, you can input the Google Doc ID in the docId field and the Google Drive ID in the driveId field when you use this component in your workflow.

I decided to use this code instead:

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    google: {
      type: "app",
      app: "google",
    },
    docId: {
      type: "string",
      label: "Google Doc ID",
    },
  },
  async run({ steps, $ }) {
    const response = await axios($, {
      url: `https://www.googleapis.com/drive/v3/files/${this.docId}/export`,
      headers: {
        Authorization: `Bearer ${this.google.$auth.oauth_access_token}`,
      },
      params: {
        mimeType: "text/html",
      },
    });
    const googleDocContent = response.data;
    // Continue with the next step
  },
});

However, this is the error that I am getting:

Error - Request failed with status code 404
{"error":{"code":404,"message":"File not found: 2VwdrkzlCdxR2CzydnWOA1GeK0M.","errors":[{"message":"File not found: 2VwdrkzlCdxR2CzydnWOA1GeK0M.","domain":"global","reason":"notFound","location":"fileId","locationType":"parameter"}]}}

I’m sorry for the trouble you’re experiencing. The “File not found” error with status code 404 indicates that the Google Doc with the provided ID could not be found. Please double-check the following: 1. Make sure the docId you provided is correct and exists in your Google Drive. 2. Ensure that the account you’ve connected to Pipedream has the necessary permissions to access the Google Doc. If you’re still experiencing issues, please provide more information about the Google Drive and the Google Doc you’re trying to access, and I’ll be happy to help you further.