Skip to main content

 I am sending the request as shown below from the documentation, but for some reason, both x and y in the response are returned as 0.

I am not sure if this is a bug or an intended behavior.

 

request

curl --request POST \
--url https://api.miro.com/v2/boards/board_id/images \
--header 'accept: application/json' \
--header 'authorization: Bearer xxxxxx' \
--header 'content-type: multipart/form-data' \
--form x=1000 \
--form y=1000 \
--form resource='@img1.png'

 

response

{
"id": "xxxxxxxxxxxx",
"type": "image",
"data": {
"imageUrl": "https://api.miro.com/v2/boards/board_id/resources/images/xxxxx?format=preview&redirect=false"
},
"geometry": {
"width": 1024,
"height": 1024
},
"position": {
"x": 0,
"y": 0,
"origin": "center",
"relativeTo": "canvas_center"
},
"links": {
"self": "https://api.miro.com/v2/boards/board_id/images/xxxxxxxxxxxxx"
},
"createdAt": "2024-06-19T10:37:26Z",
"createdBy": {
"id": "xxxxxxxxxxxxxxx",
"type": "user"
},
"modifiedAt": "2024-06-19T10:37:26Z",
"modifiedBy": {
"id": "xxxxxxxxxxxxxxxxx",
"type": "user"
}
}

Hey @mt0922,

I think you need to change the notation of your CURL. When adding a position here, it adds the coordinates into a data object:

Hope this helps!

Cheers,
Mettin


@Mettin 
Thank you.
You mean "Create image item using URL," right? What I'm using is "Create image item using file from device."

Could you please check again?


Ah sorry my bad! I talked to the team thats responsible for this endpoint and it seems the docs are wrong and we need to update them asap!

Could you try the following?

curl --request POST \
--url https://api.miro.com/v2/boards/board_id/images \
--header 'accept: application/json' \
--header 'content-type: multipart/form-data' \
--form data='{"position":{"x":1000,"y":1000}};type=application/json' \
--form resource='@img.png'

 


@Mettin 

Thank you very much!

I tried it, and the location information was successfully reflected.


Hi @Mettin 
 

 

curl --request POST \
--url https://api.miro.com/v2/boards/board_id/images \
--header 'accept: application/json' \
--header 'content-type: multipart/form-data' \
--form data='{"position":{"x":1000,"y":1000}};type=application/json' \
--form resource='@img.png'

 

I try the above, it does not work anymore. Is there any new updates push recently?


Glad I found this. Thanks


Hey @KangLeng,

Sorry for the late response. We are still investigating the issue. We are in a conversation with the helpdesk from the tool we use for our docs to find the underlying issue why our docs are wrong. Will send an update here when we fixed it of course!

Cheers,
Mettin


Hey @KangLeng,

Sorry for the late response. We are still investigating the issue. We are in a conversation with the helpdesk from the tool we use for our docs to find the underlying issue why our docs are wrong. Will send an update here when we fixed it of course!

Cheers,
Mettin

Hey Mettin

curl --request POST \ --url https://api.miro.com/v2/boards/board_id/images \ --header 'accept: application/json' \ --header 'content-type: multipart/form-data' \ --form data='{"position":{"x":1000,"y":1000}};type=application/json' \ --form resource='@img.png'
 

Tried with this hidden feature.. It is working. My bad of having wrong form data in styling


Pfew! Happy to hear you were able to solve it. Our docs still need to be fixed so my comment stands =)


Hi Mettin, 

 

I found that the docs is not yet fix, right? 

Can you give me a example for python that is workable on position? Thank you!


Hey @Joseph Lin,

Its not fixed indeed. Its auto generated and there’s a underlaying problem we have to solve. 

The CURL snippet i shared before works and I don’t know Python so I wouldn’t know. The best I can offer is a ChatGPT translation. Hope this works!
 

import requests

url = "https://api.miro.com/v2/boards/board_id/images"
headers = {
"accept": "application/json",
"content-type": "multipart/form-data"
}

data = {
"data": '{"position":{"x":1000,"y":1000}}'
}

files = {
"resource": open("img.png", "rb")
}

response = requests.post(url, headers=headers, data=data, files=files)

print(response.status_code)
print(response.json())

Cheers,
Mettin


Reply