Posting events to an iframe with an embedded dashboard

I have a dashboard embedded in an iframe. I’m trying to add filters to it like so:

let my_iframe = document.querySelector("#root > main > iframe")
const eventPayload = JSON.stringify({
  type: "dashboard:filters:update",
  dashboard_filters: {
      "Location": "now"
    }
  }
)
my_iframe.contentWindow.postMessage(eventPayload, location.origin)

But that doesn’t work - it just returns undefined and I don’t see any changes in the dashboard or any new events in the Network tab in chrome.

What am I doing wrong?