Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-ITGlueConfigurations does not return data for a single ID #58

Closed
ecspresso opened this issue Jan 17, 2019 · 3 comments
Closed

Get-ITGlueConfigurations does not return data for a single ID #58

ecspresso opened this issue Jan 17, 2019 · 3 comments
Labels

Comments

@ecspresso
Copy link
Contributor

Steps to reproduce

Get-ITGlueConfigurations -id $some_id

Expected behavior

Returned data from IT Glue

Actual behavior

Get-ITGlueConfigurations : The remote server returned an error: (404) Not Found.
At C:\Untitled6.ps1:7 char:2
+ Get-ITGlueConfigurations -id $some_id
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-ITGlueConfigurations

Screenshots

N/A

Environment

Please share additional details about your environment. Version information for:

  • PowerShell: 5.1.17763.134
  • ITGlueAPI: 2.0.4
  • Operating System: Windows 10 (10.0.17763.0)
@ecspresso
Copy link
Contributor Author

The parameter $id is only present in the parameter set show.

$resource_uri is first set at line 98:

if($organization_id) {
    #Switch to nested relationships route
    $resource_uri = ('/organizations/{0}/relationships/configurations/{1}' -f $organization_id, $id)
}
else {
    $resource_uri = ('/configurations/{0}' -f $id)
}

but then again at line 143 because the parameter set is show:

if ($PSCmdlet.ParameterSetName -eq 'index') {
    [...]
}
else {
    #Parameter set "Show" is selected; switch to nested relationships route
    $resource_uri = ('/organizations/{0}/relationships/configurations/{1}' -f $organization_id, $id)
}

$organization_id is not supplied and this results in the url /organizations//relationships/configurations/$some_id.

@ecspresso
Copy link
Contributor Author

I suggest to remove the else statement used for show. The paths will always be correct without it,

  1. $id without $organisation_id will go to $resource_uri = ('/configurations/{0}' -f $id)
  2. $id with $organisation_id will go to $resource_uri = ('/organizations/{0}/relationships/configurations/{1}' -f $organization_id, $id)
  3. $organisation_$id without id will go to $resource_uri = ('/organizations/{0}/relationships/configurations/{1}' -f $organization_id, $id), because $id is null, this effectively means '/organizations/$organisation_$id/relationships/configurations/

This in turn means that we do not need to check for parameter set show.

adrianwells pushed a commit that referenced this issue Jan 17, 2019
* Corrected path check

Get-ITGlueConfigurations did not return data when only using parameter `-id`. See #58 for more information.

* Updated patch version
@adrianwells
Copy link
Collaborator

Closing issue as it is fixed as part of release v2.0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants