Graphql api request content header error

Im using graphql to create a discounCodeApp but got 415 error code.
so is there anyway to set headers content-type for this request

const {
        discountCodeAppCreate: { codeAppDiscount, userErrors },
      } = (await shopifyClient.client.graphql(query, {
        codeAppDiscount: {
          title: discount.title,
          code: discount.code,
          startsAt: discount.startsAt,
          customerSelection: {
            all: true,
          },
          metafields: [
            {
              namespace: "$app:order-discount",
              key: "function-configuration",
              type: "json",
              value: JSON.stringify({
                percentage: discount.value,
                maximum: discount.maximum,
              }),
            },
          ],
          functionId: functionDiscount.id,
        },
      })) as {
        discountCodeAppCreate: {
          codeAppDiscount: { discountId: string };
          userErrors: { field: string[]; message: string }[];
        };
      };

image

Btw, im using Shopify from ‘shopify-api-node’ to create shopify instance

new Shopify({
          shopName: shop,
          apiVersion,
          accessToken: response.accessToken,
        })

Have you ensured you’re on the latest version of the shopify-api-node package?

1 Like