What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Using metafields under reserved namespace with Post-purchase extension

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
Community Manager
3108 344 895

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
Community Manager
3108 344 895

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