itglue / powershellwrapper

This PowerShell module acts as a wrapper for the IT Glue API.
Apache License 2.0
120 stars 51 forks source link

Set the body parameter correctly. #127

Closed lwhitelock closed 1 year ago

lwhitelock commented 3 years ago

Sets the body parameter in the get requests so it actually works

lwhitelock commented 3 years ago

There is no need to be petty this is a genuine fix to an issue with the module!

davidhaymond commented 1 year ago

Correct me if I'm wrong, but the code in question is making a GET request, which do not have bodies. Does this PR fix a specific issue you are having?

lwhitelock commented 1 year ago

Correct me if I'm wrong, but the code in question is making a GET request, which do not have bodies. Does this PR fix a specific issue you are having?

I know normally they don't but in this case IT Glue wants all the filters passed in the body of the get request. Look at line 76 onwards all the attributes are built into the body parameter. This fixes the filters for the request. I ended up forking this module and publishing ITGlueAPIv2 just to get a fix for filtering on Get-ITGlueFlexibleAssetFields to work.

ecspresso commented 1 year ago

Correct me if I'm wrong, but the code in question is making a GET request, which do not have bodies. Does this PR fix a specific issue you are having?

I know normally they don't but in this case IT Glue wants all the filters passed in the body of the get request. Look at line 76 onwards all the attributes are built into the body parameter. This fixes the filters for the request. I ended up forking this module and publishing ITGlueAPIv2 just to get a fix for filtering on Get-ITGlueFlexibleAssetFields to work.

I know this was the case a few years ago and maybe it still works, but will in the future? Looking at their documentation now, their examples have the filter and pagination parameters in the URL.

https://support.itglue.com/hc/en-us/articles/360004934397-Sorting-and-filtering-in-the-IT-Glue-API https://support.itglue.com/hc/en-us/articles/360004934057-Pagination-in-the-IT-Glue-API

davidhaymond commented 1 year ago

@lwhitelock @ecspresso I agree that moving these parameters to the query string in the URL should be the eventual goal, both because of the documentation examples and to better conform with HTTP best practices. However, it looks like most or all of the other Get-ITGlue* cmdlets also include parameters in the body instead of the query string. Since this does appear to work for now, it might be best to merge this PR to get the cmdlet working. The body issue should eventually get fixed in a future release as part of the work done on #151.