Hi, team
Since Cloudflare is migrating some dashboard I use to GraphQL, I’m trying to request some information from the Cloudflare new API in this section. Whenever I tried to query the server, I keep getting the error The remote server returned an error: (501) Not Implemented.
, I’m using PowerShell, therefore I’m using Invoke-RestMethod
cmdlet to accomplish the petition. This is the code I have so far
$oAuth2TokenUrl = "https://api.cloudflare.com/client/v4/zones/0000/analytics/dashboard"
$accessKey = '1234'
$Cloudflare_Oauth_Header = @{
"Authorization" = "Bearer $accessKey";
}
#Structure the query to GraphQL
$query = 'query {
viewer {
zones(filter: {zoneTag: "0000"}) {
httpRequests1mGroups(limit: 5, filter: { datetime_gt: "2020-02-01T04:00:00Z", datetime_lt: "2020-02-01T06:00:00Z"}) {
}
}
}'
Invoke-RestMethod -Uri $oAuth2TokenUrl -Method POST -Headers $Cloudflare_Oauth_Header -ContentType "application/json" -Body $query
Do you have any idea what am I doing wrong? It’s worth to mention I’m not that familiar with coding.