Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

curl --location --request POST "{BASE-URL}/gytpolapi/v2.0/get_misconfigurations_next" --header "x-api-key: jyUbUQNuVjClzQ5f6sXgmcgGzyoFiaYXA+OvxObvLV8=" --data-raw "{ \"token\": \"7h5vmgiKQgvFiTb3xhrSyum52cbfh77xexcus8kGtOP03mliJxbJL99q8wfC2d8kwpNGXa0QF1VuycY6xnosSJePUkaGGUgCQ61rBmVcJI1J6RkUZMWmmGGD3R/+e9b2SrRlamRNusqUBOCphAeyDpBGb7uliNLpfn7wB2JiDGDJRu73Im6UIt3V7ITZDehfsb+JkWXVLlKNIv9+RvxrBCxVa/7StHvyW10cpGF67P9HfLZFbQOCjFsFOs8Mn6amZJrh1bkpasAblUWI0toXZVrlLHr6lfEYZMRnTadcBNTNIUBBWr6ptLUvdcWqEukmdaBublWIQBpAI++Seqc9rMF2WEex9o2n+5NyQBp8+OnuvsUcUybW/MfjG6J/06d07Tf/ks9mQJgZO2vnuJQAPA==\"}"

Powershell:

Code Block
languagepowershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add( @{
    "x-api-key", = "{API KEY}")
    $headers.Add("Content-Type", = "application/json")
}
$body = "{`"Token`":{TOKEN}}"
$outputData = @()

$response = Invoke-RestMethod -Uri 'https://{BASE- URL}/gytpolapi/v2.0/get_misconfigurations_nextstart' -Method 'POST' -Headers $headers -Body $body

$responsedo | ConvertTo-Json{
    # Convert response to JSON and output
    $response | ConvertTo-Json -Depth 3

    # Accumulate data for each iteration
    $outputData += $response

    # Prepare next request body
    $body = @{ token = $response.token } | ConvertTo-Json

    # Make next request
    $response = Invoke-RestMethod -Uri 'https://{BASE URL}/gytpolapi/v2.0/get_misconfigurations_next' -Method 'POST' -Headers $headers -Body $body
} until ($response.computers.Count -eq 0)

# Export all the data to a JSON file in C:\temp folder
$outputData | ConvertTo-Json | Set-Content -Path "C:\path\to\output_data.json"


Note: Change BASE-URL to your base URL. Change x-api-key to your API key.

...