Question

Image upload does not use position and parent link property

  • 11 June 2024
  • 5 replies
  • 62 views

Badge +1

Hello 
Currently I am using this API request to upload a file from devise to an mirro boad.
Create image item using file from device - https://api.miro.com/v2/boards/{board_id}/images
But I have notice in response that passed parameters from forma-data is not applied to the image that was uploaded recently. But everything is working fine if use image link not a file to upload to boad.
Is it a bug or feature?)


5 replies

Userlevel 6
Badge +4

Hey @Pavlo Holovko,

Thanks for reaching out, and happy to help. As a first step, can I kindly ask that you double check how you’re passing the JSON body?

This endpoint expects the following field names (keys) for the multipart/form-data:
`resource` for the image file upload
`data` for the JSON file upload

And when using this endpoint, the JSON body must be uploaded as a file (.json) to be properly read by the request. Can you confirm this is how you’re uploading the JSON?

Here is an example in cURL:

curl --location --request PATCH 'https://api.miro.com/v2/boards/{boardId}/images/{imageId}' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Bearer {token}' \
--form 'resource=@"/{pathToFile}"' \
--form 'data=@"/{pathToFile}"'

Let me know, thanks!

Badge +1

Hi 
no I have not send in this way 
I send like at the example according to documentation https://developers.miro.com/reference/create-image-item-using-local-file-2

curl --location 'https://api.miro.com/v2/boards/{boardId}/images' \
--header 'accept: application/json' \
--header 'authorization: Bearer {token}' \
--form 'x="2500"' \
--form 'y="2000"' \
--form 'id="parentId"' \
--form 'title="test"' \
--form 'resource=@"/{pathToFile}"'

can you send example of data parameter 
How should it looks like?

Badge +1

I have tried something like this but get an error

data.json

{
"data": {
"title": "TestName"
},
"position": {
"x": 2000,
"y": 2000
},
"parent": {
"id": "parentId"
}
}



 

Userlevel 1
Badge +1

I am also facing the same issue. 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"
}
}

 

Userlevel 1
Badge +1

@Pavlo Holovko 

It has been resolved on our end.

https://community.miro.com/developer-platform-and-apis-57/image-upload-does-not-use-position-and-parent-link-property-16779?postid=63094#post63094

Reply