GraphQL query problem with Danish letters in SKU

So when i am doing this query:

{ shop { products(first: 1, query: "sku:\"UR-KURRELØKO-0100\"") { edges { node { title bodyHtml variants(first: 5) { edges { node { barcode displayName title } } } metafields(first: 10) { edges { node { key value } } } } } } } }

I’m getting this result:

{"response":{},"body":{"shop":{"products":{"edges":[]}}},"errors":false,"timestamps":[null,1584905996.8677]}

But doing the exact same query in Graphiql, I’m getting this - which is what I want:

{
  "data": {
    "shop": {
      "products": {
        "edges": [
          {
            "node": {
              "title": "Kurkuma Relax (Øko)",
              "bodyHtml": "<h2><strong>Wellness Te</strong></h2>\n<p>Smag denne lækre urte te, som har mass...

I expect the problem lies in the Danish letter ‘Ø’ but, why does Grahpiql accept it and not Shopify API?

Anyone has a solution on how to use ‘ÆØÅ’ letters in my SKU query as they are used a lot in the SKU?

PS: Sorry if you have seen this post before. I mixed up some logins and posted from wrong one :frowning:

Hi @bubandt

Can you remove the quotes around the SKU and try again? It would look something like:

Let me know how that goes.

Sorry no, same result:

{
  shop {
    products(first: 1, query: "sku:VÆ-MORTEMEDSK-0250") {
      edges {
        node {
          title
          bodyHtml
          variants(first: 5) {
            edges {
              node {
                barcode
                displayName
                title
              }
            }
          }
          metafields(first: 10) {
            edges {
              node {
                key
                value
              }
            }
          }
        }
      }
    }
  }
}

Gives:

{"response":{},"body":{"shop":{"products":{"edges":[]}}},"errors":false,"timestamps":[null,1585141169.6082]}

Please remember that I do get positive results when I run the query in GraphiQL - but not from my PHP API query.

Everything works in the API call when the SKU does not include Danish characters!

So getting more and more frustrated.

I can change the same SKU so it includes a Danish character “Ø” an the query will fail and the same SKU without the “Ø” will succeed???

So a product has the SKU “GR-GREGARTE-0100” and query is SUCCESS

But if the same product has the SKU “GR-GREGARTEØ-0100” the query FAILS

Only thing changed on the product is the SKU - everything else is the same.

I’m lost so any hint on what to try is very welcome.

Hey @bubandt

So just for clarity - if you do the call in a client like Postman / Insomnia to the Shopify API this succeeds? I would imagine so, similar to my screenshot. Only in your PHP app you are seeing the error, correct? Are you using any SDK or module to connect to Shopify that is third party?

Sorry for the late reply… but problem solved.

The short story is - my own fault :frowning:

Problem was solved by replacing “æ” with “\u00E6” etc. So Danish characters with the Unicode codes.

But that let me thinking why on earth I was handling HTML Entities…
Looking back in the code I found that I for some reason have translated Special characters into HTML Entities :frowning:

Removing this in the code suddenly made everything behave as desired.