Using metafields under reserved namespace with Post-purchase extension

alexander_v
Shopify Partner
3 0 0

Hey guys!

 

I want to use SetMetafieldChange in my Post-Purchase extension in combination with metafield under reserved namespace. And no matter what configuration I'm trying, it fails every time. (Works with non-reserved namespaces though). 

Changeset I'm signing:

 

 

 {
      "type": "set_metafield",
      "namespace": "$app:post-purchase",
      "key": "key",
      "valueType": "json_string",
      "value": "{\"key\": 1}"
    }

 

 

Metafield definition:

 

 "createdDefinition": {
                "id": "gid://shopify/MetafieldDefinition/1",
                "access": {
                    "admin": "MERCHANT_READ"
                },
                "description": "Description",
                "key": "key",
                "name": "name",
                "namespace": "app--11111111--post-purchase",
                "ownerType": "ORDER",
                "pinnedPosition": null,
                "type": {
                    "category": "JSON",
                    "name": "json",
                    "supportedValidations": [
                        {
                            "name": "schema",
                            "type": "json"
                        }
                    ],
                    "supportsDefinitionMigrations": true
                },
                "useAsCollectionCondition": false,
                "validationStatus": "ALL_VALID",
                "validations": []
            },
            "userErrors": []
        }

 

 

 

An error I'm getting:

 

{
    "errors": [
        {
            "code": "server_error",
            "message": "Error adding metafield $app:post-purchase:key to order"
        }
    ],
    "status": "unprocessed"
}

 

 

 

Does it mean I can't use protected namespaces to set metafield inside post_purchase? Or am I missing something?

Replies 3 (3)
Liam
Shopify Staff
Shopify Staff
1882 202 577

Hi Alexander_v,

 

Can you confirm that you're using the correct API client ID as the parameter in the name space? The example in the docs shows that if your API client ID was 123456, then your resolved reserved namespace would resolve to look like this: app--123456--some-namespace. 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

alexander_v
Shopify Partner
3 0 0

Hi Liam!

Yep, I'm using correct ID. I tried both, using just $app prefix and fully resolved namespace like  app--123456--some-namespace

Liam
Shopify Staff
Shopify Staff
1882 202 577

If this is still not working I'd recommend reaching out to Partner Support directly to look deeper into the call and store in order to test this out and determine what's happening here. You can open a support ticket via the Support section of your partner dashboard.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog