Hi everyone,
I’m trying to create a custom metafield definition for products using the Admin GraphQL API, but I keep getting a vague 400 Bad Request response with no detailed error message when calling this from my custom app running in a development store.
The goal is to create a metafield definition for products, and then set metafields.
What I am doing:
Mutation:
mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) {
metafieldDefinitionCreate(definition: $definition) {
createdDefinition {
id
name
}
userErrors {
field
message
code
}
}
}
variables:
{
“definition”: {
“name”: “Custom Field”,
“namespace”: “custom_app”,
“key”: “custom_field”,
“description”: “Test custom field for products”,
“type”: “json”,
“ownerType”: “PRODUCT”
}
}
This worked in the GraphiQL and got a successfull call.
but when calling this mutation in my custom Remix app, I always get this error:
ensureBadgeMetafieldDefinition failed: Response {
status: 400,
statusText: ‘’,
headers: Headers { ‘Content-Type’: ‘application/json; charset=utf-8’ },
body: ReadableStream { locked: false, state: ‘readable’, supportsBYOB: true },
bodyUsed: false,
ok: false,
redirected: false,
type: ‘default’,
url: ‘’
}
Shopify error JSON: {
“errors”: {
“networkStatusCode”: 400,
“message”: “GraphQL Client: Bad Request”,
“response”: {}
}
}
Current scopes:
- read_products
- write_products
- read_themes
- write_themes
I have tried refreshing app install and scopes multiple times.
Am I missing something?
Could this be an authentication issue?
Any help or insight would be greatly appreciated!