'Try to recreate API-request?
i try to recreate the request for this site: https://www.dolthub.com/repositories/dolthub/ip-to-country
and i try it with this code: (is copied the full payload source content from the network-tab)
import requests import os import sys
if __name__ == '__main__':
payload = {"operationName":"RowsForDataTableQuery","variables":{"ownerName":"dolthub","repoName":"ip-to-country","refName":"master","tableName":"IPv4ToCountry","revisionType":2},"query":"query RowsForDataTableQuery($ownerName: String!, $repoName: String!, $refName: String!, $revisionType: Float!, $tableName: String!, $pageToken: String) {\n rows(\n ownerName: $ownerName\n repoName: $repoName\n revisionName: $refName\n tableName: $tableName\n revisionType: $revisionType\n pageToken: $pageToken\n ) {\n ...RowListRows\n __typename\n }\n}\n\nfragment RowListRows on RowList {\n nextPageToken\n prevPageToken\n list {\n ...RowForDataTable\n __typename\n }\n __typename\n}\n\nfragment RowForDataTable on Row {\n columnValues {\n displayValue\n __typename\n }\n __typename\n}\n"}
headers = {
'access-control-allow-credentials':'true',
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
}
url = "https://www.dolthub.com/graphql"
resp = requests.post(url,data=payload, headers=headers)
# resp = requests.post(url,headers=headers)
print(resp.status_code)
resp = resp.json()
print(resp)
But i allways get this response and error-message when running the code:
400
{'errors': [{'message': 'Variable "$ownerName" of required type "String!" was not provided.', 'locations': [{'line': 1, 'column': 29}], 'extensions': {'code': 'BAD_USER_INPUT'}}, {'message': 'Variable
"$repoName" of required type "String!" was not provided.', 'locations': [{'line': 1, 'column': 50}], 'extensions': {'code': 'BAD_USER_INPUT'}}, {'message': 'Variable "$refName" of required type "String!" was not provided.', 'locations': [{'line': 1, 'column': 70}], 'extensions': {'code': 'BAD_USER_INPUT'}}, {'message': 'Variable "$revisionType" of required type "Float!" was not provided.', 'locations': [{'line': 1, 'column': 89}], 'extensions': {'code': 'BAD_USER_INPUT'}}, {'message': 'Variable "$tableName" of required type "String!" was not provided.', 'locations': [{'line': 1, 'column': 112}],
'extensions': {'code': 'BAD_USER_INPUT'}}]}
Why is this not working? There is a ownername for example as string in the payload but i still get the error-message?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
