Answered

Unable to get CARD metadata with REST API

  • 9 September 2020
  • 1 reply
  • 880 views

Hi community.

 

I want to develop an application that use card metadata.

Unfortunately, I can add metadata to the card with JavaScript SDK, but I can’t get it with REST API.

Do you know why?

 

Reproduction procedure

(0) Create Application

https://developers.miro.com/docs/getting-started

(1) Create a card with SDK

await miro.board.widgets.create({
type: "card",
text: "test card",
metadata: {
[appId]: {
hoge: true,
},
}
})

(2) Get the card with REST API

curl --request GET \  --url https://api.miro.com/v1/boards/${board_id}/widgets/${widget_id}\  --header 'authorization: Bearer ${token}'

→ No metadata

 

Thank you.

icon

Best answer by Daniela Gavidia 16 October 2020, 13:25

View original

1 reply

Userlevel 4
Badge

Hello,

I just tested this and it works if you make the call in the code for your web-plugin, like this:
 

miro.board.widgets.create({
type: "sticker",
text: "TEST",
metadata: {
"1234567890471107053": {
data: "test data",
},
}
})

However, if you are calling the SDK from your browser Javascript console, you have to make sure that you set the right Javascript context. You should choose your web-plugin as the context, otherwise it won’t work. Like this:
 


See also:

https://stackoverflow.com/questions/53426995/firefox-dev-tools-change-js-execution-context
 

I hope this helps.

Kind regards.

 

Daniela

Developer Experience Team @ Miro

Reply