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!
Best answer by Joe DuffyView original
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/uploadInclude the file as a parameter called
fileand upload it as multipart/form-data.
The response looks like this:
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.
Thank you very much - I will try it.