REST API update geometry errors

  • 24 August 2022
  • 5 replies
  • 114 views

Badge +1

Hi, I’m having problems changing the geometry of a card.

e.g. (from python)

payload = { 'geometry':{'width':260, 'height':130}}

url = f"https://api.miro.com/v2/boards/uXjVPdveOFo=/cards/3458764531765310379"

response = requests.patch(url, json=payload, headers=headers).json()

results in 

{'type': 'error', 'code': '3.0215', 'context': {'boardId': 'uXjVPdveOFo=', 'itemId': '3458764531765310379', 'validationErrors': [{'code': '3.0211', 'message': 'Value for width should be greater than or equal to 256.0, found: 147.39173256538714'}]}, 'message': 'Unable to complete operation because of the validation errors.', 'status': 400}
 

which doesn’t make sense as the width I’m setting is > 256. It seems if the card has been manually resized at some point, the API call will either get ignored (response returns the size set, but item on canvas does not change) or it returns a nonsensical error.

Is this a bug in the API?


5 replies

Userlevel 5

Hey @Alexei, sorry to hear this is happening. Can you try removing height from the payload, and let me know if you can successfully send a request?

 

Badge +1

Hi @Addison Schultz, if only the width is sent I still get the error, if only the height is sent I get no error, response has new size, but card is not resized, (also tried closing and reopening board in case it was a refresh problem).

The card in question was manually resized. For a card that has not been manually resized the geometry commands work fine. 

Manually changing colour or position does not affect ability to change those attributes via API, only geometry seems affected.

Userlevel 2
Badge +1

Hi @Alexei,

I tried to reproduce the issue you reported with both the Web SDK (I used a sample app and the browser developer console), and REST API (I used the REST API playground on the REST API developer docs site and Postman.)

This is what I did:

  1. Create a card with REST API/Web SDK.
  2. Resize it manually on the board UI.
  3. Update only the card geometry with REST API/Web SDK.

Expected result:

  • The card on the board reflects the geometry update that was applied programmatically.

Actual result:

  • The card on the board keeps the old geometry values. Geometry is not updated on the board UI after manually resizing the card.

I could not achieve your outcome. The steps I went through produced the expected result: the card geometry was updated successfully.

 

I'm opening a ticket on our end to ask the REST API team to investigate the issue more in depth.

 

Do you think you could share a screen recording video to help us better understand what could be causing the issue? This would give us some guidance as for what to look for. 

Badge +1

I’ll do a screen recoding but here’s some further points:

There is two things I can do to manually change the size of a card:

  1. dragging the left edge changes the width, there is a minimum width and no apparent maximum. Dragging the bottom edge changes the height, there is a minimum height and a maximum height related to content (once all lines on title are exposed I can't increase height any more). So the aspect ratio is contained based on content.
  2. I can drag the corner of a card. This seems to scale a card and there are no limits on size.

So I can scale a card manually, then programatically attempt to set the width to 30, I get the error: ‘Value for width should be greater than or equal to 256.0, found: 68.61018854841734'.

If I manually scale the card down and try again to set width to 30 I get: 'Value for width should be greater than or equal to 256.0, found: 130.876884331362'

If I then scale the card down sufficiently and set the width to 30 It’s successful. The tool tip on the board reports a width of 30 as does the response.

There’s two things going on as far as I can see: firstly there are aspect ratio constraints to do with the content that limit the height values. Secondly there seems to be a hidden scale/units parameter that is not accessible programatically. i.e. constraints are being applied at a scale that can be changed manually but can't be accessed by the API, this is why the reported width found changes even though I’m always setting a width of 30.

Badge +1

To produce an error, create a card:

payload = {

    'data':{'title':'Sample card'},

    'geometry':{'width':300}

}

url = f"https://api.miro.com/v2/boards/uXjVPdveOFo=/cards"

response = requests.post(url, json=payload, headers=headers).json()

 

Manually tap on card to bring up handles and scale to twice the size. Now try and set the width to 300 which should be legal:

card_id = response['id']

payload = {

    'geometry':{'width':300}

}

url = f"https://api.miro.com/v2/boards/uXjVPdveOFo=/cards/{card_id}"

response2 = requests.patch(url, json=payload, headers=headers).json()

I get the error

{'type': 'error', 'code': '3.0215', 'context': {'boardId': 'uXjVPdveOFo=', 'itemId': '3458764532060721253', 'validationErrors': [{'code': '3.0211', 'message': 'Value for width should be greater than or equal to 256.0, found: 150.80322771377394'}]}, 'message': 'Unable to complete operation because of the validation errors.', 'status': 400}

where the found value of 150 is half the requested width

Scale to 3 times the size and the result is:

{'type': 'error', 'code': '3.0215', 'context': {'boardId': 'uXjVPdveOFo=', 'itemId': '3458764532060721253', 'validationErrors': [{'code': '3.0211', 'message': 'Value for width should be greater than or equal to 256.0, found: 100.71525688814353'}]}, 'message': 'Unable to complete operation because of the validation errors.', 'status': 400}

which is a 1/3 of requested size etc.

Reply