Skip to main content
Answered

Image upload does not use position and parent link property


Forum|alt.badge.img+1

 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"
  }
}

Best answer by Mettin

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'

 

View original
Was it helpful?

11 replies

Mettin
Mironeer
Forum|alt.badge.img+1
  • Mironeer
  • 86 replies
  • June 20, 2024

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


Forum|alt.badge.img+1
  • Author
  • Beginner
  • 4 replies
  • June 20, 2024

@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?


Mettin
Mironeer
Forum|alt.badge.img+1
  • Mironeer
  • 86 replies
  • Answer
  • June 20, 2024

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'

 


Forum|alt.badge.img+1
  • Author
  • Beginner
  • 4 replies
  • June 24, 2024

@Mettin 

Thank you very much!

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


Forum|alt.badge.img+1
  • Beginner
  • 3 replies
  • June 27, 2024

Hi @Mettin 
 

Mettin wrote:

 

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?


Forum|alt.badge.img

Glad I found this. Thanks


Mettin
Mironeer
Forum|alt.badge.img+1
  • Mironeer
  • 86 replies
  • August 12, 2024

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


Forum|alt.badge.img+1
  • Beginner
  • 3 replies
  • August 12, 2024
Mettin wrote:

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


Mettin
Mironeer
Forum|alt.badge.img+1
  • Mironeer
  • 86 replies
  • August 12, 2024

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


Forum|alt.badge.img
  • New Here
  • 1 reply
  • August 23, 2024

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!


Mettin
Mironeer
Forum|alt.badge.img+1
  • Mironeer
  • 86 replies
  • August 26, 2024

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