Jump to content

Any reason why a working script would no longer work - getting 200 response but no data


Dan P

Recommended Posts

I have what was a working PowerShell script to get a list of all my systems in Pulseway.  It is no longer working. I am getting a 200 response, just no data. I even tried to replicate it in Node JS since there is official documentation for it, but I get the same response - 200 but no data.

$username = 'administrator'
$password = '*************'

#Adding credentials to header
$header = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($username):$($password)")) }

#Call API to return first 100 systems - calls are limited to 100 results
$first100 = Invoke-RestMethod -uri https://xxxxxxxxxxxx.pulseway.com/api/v2/systems -Method GET -Header $header -ContentType "application/json"
#Call API to return second 100 systems using offset of 100 as a query
$second100 = Invoke-RestMethod -uri https://xxxxxxxxxxx.pulseway.com/api/v2/systems?offset=100 -Method GET -Header $header -ContentType "application/json"

#Create and calculate variable for total number of systems counted
$total = 0
$total += $first100.data.length
$total += $second100.data.length

Foreach ($r in $first100.data) {
    If ($r.name[6] -match "-" -and $r.group -match "US Workstations") {
        Write-Host $r.name
    }
}

Foreach ($r in $second100.data) {
    If ($r.name[6] -match "-" -and $r.group -match "US Workstations") {
        Write-Host $r.name
    }
Link to comment
Share on other sites

I cannot replicate the issue:

I have just run your script, only modifying the password, the URI, and I removed the IF statement so it returned all hosts.  

It worked first time. I suggest you raise this with Support, as it is most likely to be something with your tenancy - and hopefully they can see why?  

Would appreciate you posting the solution if you get it! I'm going to embark on API integration soon, so I may come across similar issues!

Thanks, 

Link to comment
Share on other sites

@Jamie Taylor - I've mentioned this before to our account manager and in general feedback, but is it possible that customers could get a list of defects resolved per release? Its frustrating to not know what has or hasn't been fixed. All we see in the release notes is the new features, not development that has improved existing functionality. 

 

FYI - This should not be a feature request, this is something nearly all SaaS companies do in one way or another. Please don't direct me to the feature request upvoting site!

Edited by WYE
missed out the word "not"!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...