REST API: How to put images on a board?

  • 25 December 2022
  • 0 replies
  • 115 views

Badge +1

Hi,

 

I’m trying to put a image to a Miro board via the REST API (https://developers.miro.com/reference/create-image-item-using-file-from-device).

 

I tried different variants of the code below. Error ranging from 400 to 415.

 

 

        headers = {'Authorization': 'Bearer <token>',

                   'Content-type': 'multipart/form-data',

                   'Accept': 'application/json'}

        json_data_as_json = {

            "title": "title for the image",

            "position": {

                "x": 100,

                "y": 200,

                "origin": "center"

            },

            "geometry": {

                "width": 100,

                "height": 100,

                "rotation": 0

            }

        }

        response = requests.request("POST", url, json=json_data_as_json,

                                    data={'resource': base64.b64encode(open('c:/temp/test.png', 'rb').read())},

                                    headers=headers,

                                    verify=False)

 

 

 Any idea what is wrong?

Or could someone provide a code snippet which works?

 

Thanks and Regards,

Sebastian


0 replies

No replies yet...

Reply