Skip to main content

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: e],
  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: n
{
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'
}
});

 

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!


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!


Reply