Skip to main content
Solved

Struggling with import API - Document Created but no shapes

  • September 23, 2024
  • 5 replies
  • 93 views

Forum|alt.badge.img+1

Really struggling with the import API.  I’m getting the oAuth2 tokens successfully, able to create documents just fine, but they don’t have anything in them even though i’m sending off json for creation.  Trying to mimic the jira to Lucid as closely as possible, but it’s not working out.  Logs indicate success, but that’s because the documents are getting created.

My log:
Create Document Response: {
  documentId: '369afc52-f1f2-41ee-be08-fd63581fe00f',
  title: 'Updated Test Document with Shapes',
  editUrl: 'https://lucid.app/lucidchart/xxxxx/edit',
  viewUrl: 'https://lucid.app/lucidchart/xxxxx/view',
  version: 110,
  pageCount: 1,
  canEdit: true,
  creatorId: 136597754,
  lastModified: '2024-09-23T14:50:45Z',
  lastModifiedUserId: 136597754,
  trashed: null,
  status: 'Draft',
  classification: null,
  customAttributes: [],
  customTags: [],
  parent: 383364222,
  product: 'lucidchart',
  created: '2024-09-23T14:50:45Z'
}

 

    // Define the shapes using the structure from the example
    const documentData = {
      title: "Updated Test Document with Shapes",
      product: "lucidchart",
      pages: [
        {
          id: "page1",
          title: "Main Plan",
          shapes: [
            {
              id: "rect1",
              type: "stickyNote", // Use a predefined shape type like in the example
              boundingBox: {
                x: 100,
                y: 100,
                w: 200,
                h: 100
              },
              style: {
                fill: {
                  type: "color",
                  color: "#ADD8E6"
                },
                stroke: {
                  color: "#000000",
                  width: 1,
                  style: "solid"
                }
              },
              text: "Rectangle Shape"
            },
            {
              id: "ellipse1",
              type: "stickyNote", // Use a predefined shape type
              boundingBox: {
                x: 400,
                y: 100,
                w: 200,
                h: 100
              },
              style: {
                fill: {
                  type: "color",
                  color: "#ADD8E6"
                },
                stroke: {
                  color: "#000000",
                  width: 1,
                  style: "solid"
                }
              },
              text: "Ellipse Shape"
            }
          ],
          connections: [
            {
              id: "conn1",
              source: "rect1",
              target: "ellipse1",
              type: "line",
              style: {
                stroke: {
                  color: "#FF0000",
                  width: 2,
                  style: "solid"
                }
              }
            }
          ]
        }
      ]
    };

    // Create the document with the structured shapes and connections
    const createDocResponse = await axios.post('https://api.lucid.co/documents', documentData, {
      headers: {
        'Authorization': `Bearer ${accessToken}`,
        'Lucid-Api-Version': '1',
        'Content-Type': 'application/json'
      }
    });

 

Best answer by alec.bingham

Hey Dude95, I’m Alec, I’m one of the engineers that helped build that import functionality, hopefully I can help!

It looks like you are sending the JSON directly as the body of your request, which isn’t the format the endpoint is expecting. Because we wanted the import to be able to receive images or data files that can be referenced within the document, the endpoint expects a zip file with the extension .lucid that contains your JSON as a file named document.json , as well as any of the included image or data files.

Here’s a link to our documentation where this part is explained a bit more in depth (specifically under the “Getting Started” heading): https://lucid.readme.io/docs/overview-si

Hopefully this helps you resolve your issue, if not, don’t be afraid to reach back out!

View original
Did this topic help you find an answer to your question?

Forum|alt.badge.img+2
  • Lucid product team
  • September 24, 2024

Hey Dude95, I’m Alec, I’m one of the engineers that helped build that import functionality, hopefully I can help!

It looks like you are sending the JSON directly as the body of your request, which isn’t the format the endpoint is expecting. Because we wanted the import to be able to receive images or data files that can be referenced within the document, the endpoint expects a zip file with the extension .lucid that contains your JSON as a file named document.json , as well as any of the included image or data files.

Here’s a link to our documentation where this part is explained a bit more in depth (specifically under the “Getting Started” heading): https://lucid.readme.io/docs/overview-si

Hopefully this helps you resolve your issue, if not, don’t be afraid to reach back out!


Forum|alt.badge.img+1
  • September 25, 2024

Thanks so much for this - it is in fact the solution to my issue.  The documentation you linked helps.  Now I’m starting to understand!


Forum|alt.badge.img+5

Please fix the import process to allow direct json.  That’s how every other API in the world works.

 


Michael B
Forum|alt.badge.img+4
  • Lucid product team
  • February 11, 2025

I agree. We are working on a version that allows the json to be sent in the body directly. I do not have an ETA, but hope to release it soon.


Forum|alt.badge.img+1
  • February 11, 2025

Adding a straight forward JSON post would be great!


Reply