Skip to main content

Hello there,
we would like to publish cards via the REST API. The content of those cards should be a mix of text and images. As I'm new to the API and not too experienced with these topics, here my very basic question:

How to upload images via the REST API to be used on a card?

The documentation shows that it is possible to attach objects, but properties such as “id” or “link” suggest that the attachment has to be already uploaded. Are these optional parameters just for the case one wants to use an already uploaded file?
Are the images expected to be embedded in a multipart post-request? If yes, how to reference them in the html sources?

As an example, when using the WordPress REST API, one can upload each image individually and receive an ID and URL for each image. This can then get incorporated in the source when eventually publishing the post. How is this realized with the Guru API?

Many thanks in advance!

Hi @Oliver Müller,

Apologies for the delayed response here - we made an enhancement to our image upload API this week and wanted to give you the latest documentation.

When you are creating cards through the API, to include files or images you need to make a separate API call for each file. Once a file is uploaded then you can reference it in the card's HTML.

To upload a file to Guru, make a POST call to https://api.getguru.com/api/v1/attachments/upload Include the file as a parameter called file and upload it as multipart/form-data.

The response looks like this:

{
"mimeType": "image/png",
"link": "https://content.api.getguru.com/files/view/21641073-b2d2-4955-a9dc-44fb8cfb25f4",
"filestackKey": "014dc5f6-9488-43fe-a892-206d276a7a9c/79783795-0b4b-4414-b931-9b949f718d08-image.png",
"attachmentId": "21641073-b2d2-4955-a9dc-44fb8cfb25f4",
"filename": "image.png",
"size": 16332
}

 

The link value there is the attachment's URL. When creating a card, you can reference this attachment URL in the card's HTML to make the card link to the file, show it as an image, or embed it in an iframe.

Let me know if this helps.

Thanks!


Thank you very much - I will try it.


Hi @Joe Duffy , is there any further documentation around this solution for uploading attachments via API calls?

 

I would like to then create a card that links to the uploaded files or embeds them in iframes. A snippet of code or documentation on how to do this would be very helpful


Reply