import requests
import json
# API endpoint
API_URL = "https://beta.node.thegrid.id/graphql"
# GraphQL query
query = """
query MyQuery {
profileInfos(limit: 10) {
name
descriptionShort
icon
logo
}
}
"""
payload = {"query": query}
headers = {'Content-Type': 'application/json'}
try:
response = requests.post(API_URL, json=payload, headers=headers)
response.raise_for_status()
result = response.json()
print("Success!")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
except json.JSONDecodeError:
print(f"Invalid JSON response: {response.text}")