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": ...
}
{
"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)
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}"
"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}"
...
Jump to solution
6 Replies
nerdylive
nerdylive7mo ago
It is said there, it's unaothorized
digigoblin
digigoblin7mo ago
Yeah means the API key is invalid.
nevermind
nevermindOP7mo ago
OK, why I can see my pods then with this API key in the same response? Also if I remove machines from query, I receive a response with no error
digigoblin
digigoblin7mo ago
Then you don't have access to machines "you" meaning your API key
nevermind
nevermindOP7mo ago
I understand. Can you tell me what should I do to obtain machines? Or dataCenter of pods (that would be enough)
Solution
nevermind
nevermind7mo ago
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}"
"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}"
"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
Want results from more Discord servers?
Add your server