graphql Unauthorized

When I perform the "myPods" query [https://graphql-spec.runpod.io/#query-myself looks similar] with the "machines" field, I receive a strange output:
{
  "errors": [
    {
      "message": "Unauthorized",
      "locations": [
        {
          "line": 15,
          "column": 3
        }
      ],
      "path": ["myself", "machines"],
      "extensions": {
        "code": "RUNPOD"
      }
    }
  ],
  "data": ...
}

The "data" field contains normal data but without "machines".
  1. Why am I facing "Unauthorized"?
  2. How do I filter my pods by dataCenter's value?
Script to reproduce:

import requests

query = {
    "operationName":"myPods",
    "variables":{},
    "query":"query myPods {\n  myself { pods {\n   desiredStatus \n      dockerId\n     id\n      imageName\n      lastStatusChange\n     locked\n      machineId\n   name\n      machineType\n      templateId\n      uptimeSeconds\n     }\n  machines { id }   }\n}"
}
r = requests.post(
    "https://api.runpod.io/graphql?api_key=...",
    json=query
)
print(r.content)
print(r.status_code)
Solution
The solution was given on Slack
I had to use this query not like
"query myPods {\n  myself { pods {\n   desiredStatus \n      dockerId\n     id\n      imageName\n      lastStatusChange\n     locked\n      machineId\n   name\n      machineType\n      templateId\n      uptimeSeconds\n     }\n  machines { id }   }\n}"

But
"query myPods {\n  myself { pods {\n   desiredStatus \n      dockerId\n     id\n      imageName\n      lastStatusChange\n     locked\n      machineId\n   name\n      machineType\n      templateId\n      uptimeSeconds\n   **machine { id }**  }\n   }\n}"

Note, that gql spec is outdated
Was this page helpful?