Graphql query to get order info by name not working in curl command!

I have a graphql query to get order information for a given order name. It works correctly in the GraphiQL app. But it does not work as a curl command. I use the same api version 2025–07. The query is to my dev store quickstart-225a1b25.myshopify.com. I have the read_orders scope. I can confirm that an order with name #1004exists on the store.

Here is the curl command with the access token revoked:

curl --location 'https://quickstart-225a1b25.myshopify.com/admin/api/2025-07/graphql.json' \
--header 'X-Shopify-Access-Token: [OAUTH_TOKEN]' \
--header 'Content-Type: application/json' \
--data '{"query":"query GetOrderByName {\n  orders(first: 1, query: \"name:#1004\") {\n    edges {\n      node {\n        id\n        name\n      }\n    }\n  }\n}","variables":{}}'

Any idea what I am missing? How is it working in graphiql but not curl?

Here is the response I get for the curl command. Clearly it is not an auth error

{
    "data": {
        "orders": {
            "edges": []
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 3,
            "actualQueryCost": 2,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1998,
                "restoreRate": 100.0
            }
        }
    }
}

Wrap or escape the #, e.g. query: "name:\"#1004\"" or query: "name:\#1004" (or URL-encode %231004). Had to fix this on a client build, Shopify search syntax requires quoting/escaping special characters.

I am unable to read any order, not just the order with name #1004. I verified my app has the scope read_orders. I regenerated a new token. Yet no luck!

@Moid.space Thanks for the idea but it seems like my issue is not a filter issue. I am unable to get any order info with no filters. Here’s the query I used:

query GetOrderByName {
  orders(first: 1) {
    edges {
      node {
        id
        name
      }
    }
  }
}

Never mind! found the issue. read_orders gives access to past 60 days orders. My dev store orders were older than 60 days.