App Owned Metafield Create fails

A query on App Installation with a valid API key to a store returns an ID:

"data": {
  "appInstallation": {
    "id": "gid://shopify/AppInstallation/35972"
  }
}

I want to make a Storefront API token I have visible via Liquid to my Theme App Extension, so make some calls, so I want to store this token in an App Owned Metafield, thus allowing me to render the Storefront API token in Liquid.

A call to the App Owned Metafield Create returns invalid ID to me. I see no reason for this. What is the secret sauce to setting an App Owned Metafield?

My data to the call is straight out of the docs for the call signature.

{
  "metafieldsSetInput": [
    {
      "namespace": "moon_shot",
      "key": "storefront_access_token",
      "type": "single_line_text_field",
      "value": "gid://shopify/StorefrontAccessToken/1234567",
      "ownerId": "gid://shopify/AppInstallation/35972"
    }
  ]
}

The result:

"errors": [
		{
			"message": "invalid id",
			"locations": [
				{
					"line": 2,
					"column": 3
				}
			],
			"path": [
				"metafieldsSet"
			]
		}
	],

So what am I doing wrong here? Seems like I am using the correct ID. What is invalid?

Ack. Unhelpful error message was the culprit here. Instead of recognizing that this call needs API 2022-04 or newer, it spits out invalid ID as the error message. Shopify, please improve your error handling. With 2022-04 or newer, this mutation works fine.

Try with newer api versions, I’d the same issues with company gid and using 2023-01 api version I make my day!