Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported Content-Type header, use application/json 2025-01 #669

Open
mete89 opened this issue Dec 20, 2024 · 0 comments
Open

Unsupported Content-Type header, use application/json 2025-01 #669

mete89 opened this issue Dec 20, 2024 · 0 comments

Comments

@mete89
Copy link
Contributor

mete89 commented Dec 20, 2024

I have a simple graphql which returns Unsupported Content-Type header, use application/json 2025-01 error in 2025-01 although it works fine versions <= 2024-10.

            {
                productVariantsCount {
                  count
                  precision
                }
            }

It works fine when we add an empty object as variable to the graphql to force json usage here:

Shopify.prototype.graphql = function graphql(data, variables) {
  let pathname = '/admin/api';

  if (this.options.apiVersion) {
    pathname += `/${this.options.apiVersion}`;
  }

  pathname += '/graphql.json';

  const uri = { pathname, ...this.baseUrl };
  const json = variables !== undefined && variables !== null;
  const options = {
    agent: this.options.agent,
    body: json ? this.options.stringifyJson({ query: data, variables }) : data,
    headers: {
      ...this.baseHeaders,
      'Content-Type': json ? 'application/json' : 'application/graphql'
    },
    method: 'POST',
    parseJson: this.options.parseJson,
    responseType: 'json',
    timeout: this.options.timeout
  };

Related changelog:

https://shopify.dev/docs/api/release-notes/2025-01

JSON body support: We now provide native support of a HTTP request body as a JSON_body for function external calls. Use this field when the body is in JSON format to reduce function instruction consumption and to ensure the body is formatted in logs. Don't use the JSON_body field together with the body field in the HttpResponse object. If both are provided, then the HttpResponse's body field takes precedence. If the JSON_body field is specified and no Content-Type header is included, then the header will automatically be set to application/json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant