Skip to content

Auth error with Update Generate-Device-Alert-Heatmap.ps1 #17

@JAC1976

Description

@JAC1976

Hi Luke,

Would love to be able to use your script, there seems to be an issue with the [Update Generate-Device-Alert-Heatmap.ps1] with the latest v2 API, it's not connecting.
I am just getting started with using the API, so unsure how to fix this myself. I know my ClientID and Secret are ok, the URL is the US instance, and I get this error.
Are you able to point me in the right direction?
Thanks
Jamie

Invoke-WebRequest : { "resultCode": "FAILURE", "errorMessage": "HTTP 405 Method Not Allowed", "incidentId":
"WEB_MGMT_SERVICE-956f20578bc34edb8456583676006ba7-1754162494-WDWUOPGK" }
At C:\ProgramData\NinjaRMMAgent\scripting\customscript_gen_1754162494379_240.ps1:98 char:11

  • $Result = Invoke-WebRequest -uri "$($NinjaURL)/ws/oauth/token" -Metho ...
  •       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
      eption
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
      ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
      At C:\ProgramData\NinjaRMMAgent\scripting\customscript_gen_1754162494379_240.ps1:101 char:52
  • ... uthorization' = "Bearer $(($Result.content | ConvertFrom-Json).access ...
  •                                              ~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertFrom
      JsonCommand

Invoke-WebRequest : {"error":"missing_header","error_description":"Missing required header","error_code":2}
At C:\ProgramData\NinjaRMMAgent\scripting\customscript_gen_1754162494379_240.ps1:108 char:13

  • $Devices = (Invoke-WebRequest -uri "$($NinjaURL)/api/v2/devices" -Met ...
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
      eption
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions