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

Does not upload to ITGlue because the following error. #4

Open
MartinRiley opened this issue Jan 3, 2018 · 12 comments
Open

Does not upload to ITGlue because the following error. #4

MartinRiley opened this issue Jan 3, 2018 · 12 comments

Comments

@MartinRiley
Copy link

Invoke-RestMethod : {"errors":[{"status":401,"title":"Unauthorized","detail":"Unauthorized resource
access","source":{"pointer":"id"}}]}
At C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI\Resources\FlexibleAssets.ps1:12 char:20

  • $rest_output = Invoke-RestMethod -method "POST" -uri ($ITGlue_Base_URI + $re ...
    
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
     eption
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    
    

for what i can see it looks like i did not put in the correct Uri?? But we dont use a gateway or anything so in my eyes it has to be the default uri?

other then that it seems because of the "Unauthorized resource access" that i dont have access to my own ITGlue.

an other problem that keep occuring and this might be relevant is that as soon as i type in Get-ITGlueAPIKey it doesent show me my apikey even with the Force command.

PS C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI> Get-ITGlueAPIKey
System.Security.SecureString
Use Get-ITGlueAPIKey -Force to retrieve the unencrypted copy.
PS C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI> Get-ITGlueAPIKey -Force
System.Security.SecureString
Use Get-ITGlueAPIKey -Force to retrieve the unencrypted copy.
PS C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI> .\ActiveDirectory.ps1 -api api_config-ActiveDirectory.psd1

So if anyone can help me with what im doing wrong let me know thx :)

@taylormaguire
Copy link

I'm having the same issue, any fix for this yet?

@CalebAlbers
Copy link
Collaborator

Hey MartinRiley,

Pardon the delay in response, I have been out of state for a while now and am catching up.

Would you be able to run Get-ITGlueBaseURI? If you are using IT Glue's API without any proxies or other more advanced use cases, you should just get http://api.itglue.com as the output. If you do not, please run Add-ITGlueBaseURI without parameters to make it default to the http://api.itglue.com address.

If you are still getting an error, I would suggest re-adding your API key. Afterwards, it is advantageous to run Export-ITGlueModuleSettings so that the working URI and API key are auto-imported when you load the module.

As for the Get-ITGlueAPIKey, it will not return the unencrypted API key even with the -Force parameter as a security measure, as your API key is able to access all IT Glue data across all organizations, which can be somewhat dangerous if given in plaintext. As such, it returns an object that contains the encrypted version. The -Force option is depreciated and I appreciate you bringing it to my attention, as it was meant to be removed.

You are able to unencrypted your API key if you so desire by running (New-Object System.Management.Automation.PSCredential 'N/A', $ITGlue_API_Key).GetNetworkCredential().Password), which is a PowerShell cmdlet built for managing SecureStrings. It uses reversible encryption tied to your user principle (user account on your specific Windows device).

Please let me know if setting the Base URI to the default works. If not, let's run Get-ITGlueUsers or some other command to test that the module is set up properly before continuing on with the ActiveDirectory script troubleshooting.

@MartinRiley
Copy link
Author

MartinRiley commented Jan 21, 2018 via email

@MartinRiley
Copy link
Author

MartinRiley commented Jan 21, 2018 via email

@MartinRiley
Copy link
Author

@CalebAlbers when i ran it the first time i did use the default baseurl. (it was the http://api.itglue.com)
And it did not work then. I think when i posted this it was with the base default api url.

I later on tried to do it with the company url and kept having the same problem.

I havent run the Get-ITGlueUsers yet.
You have any kind of reference of how i can see that i do it in the correct way and get the correct output.

Or is there a way (maybe email) we can have some contact where i can sent some screenies :)

First time working with Powershell Scripts so i might completly forget something or do something totally wrong. I have screenshots of the time i posted this.

Greetings

@MartinRiley
Copy link
Author

PS C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI> Get-ITGlueUsers

data links meta


{@{id=68079; type=users; attributes=... @{current-page=1; next-page=; prev-p...

PS C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI>

as you can see this is the outcome for the get users command.

@jhill777
Copy link

jhill777 commented Mar 2, 2018

Getting Global Catalog Servers (Domain Controllers)...
DC02,DC01,DC03,DC04
Active Directory flex asset configuration file found!
No flexible asset id was found... creating a new flexible asset.
Invoke-RestMethod : {"errors":[{"status":422,"title":"Unprocessable Entity","detail":"Request contains invalid trait keys","source":{"pointer":"data/attributes/traits"}}]}
At C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI\Resources\FlexibleAssets.ps1:12 char:20

  • $rest_output = Invoke-RestMethod -method 'POST' -uri ($ITGlue_Base_URI + $re ...
    
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    
    
    

PS C:\Users\jhill\Downloads\Active Directory> $output.data.attributes.'name-key'
forest-name
domain-full-name
domain-short-name
ad-level
schema-master
domain-naming-master
relative-id-rid-master
pdc-emulator-master
infrastructure-master
global-catalog-servers-domain-controllers

api_config-ActiveDirectory.psd1:
#>

key_name_ADForestName = 'forest-name'
key_name_DomainName = 'domain-full-name'
key_name_DomainShortName = 'domain-short-name'
key_name_ADFunctionalLevel = 'ad-level'
key_name_SchemaMaster = 'schema-master'
key_name_DomainNamingMaster = 'domain-naming-master'
key_name_RIDMaster = 'relative-id-master'
key_name_PDCEmulator = 'pdc-emulator-master'
key_name_InfrastructureMaster = 'infrastructure-master'
key_name_GlobalCatalogServers = 'global-catalog-servers-domain-controllers'

Any ideas?
I've already completely deleted the Flexible Asset and recreated it to no avail.

@reneehildebrand
Copy link
Contributor

relative-id-rid-master?

@jhill777
Copy link

jhill777 commented Mar 3, 2018

Wow...I'm embarrassed to admit how long I stared at this. Thank you!!!!!!

@jhill777
Copy link

Is there a limitation on 2016 for the AD level?
Invoke-RestMethod : {"errors":[{"source":{"pointer":"/data/attributes/flexible-asset-traits.ad
level"},"detail":["can't be blank"],"title":"Unprocessable Entity","status":422}]}
At C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI\Resources\FlexibleAssets.ps1:12 char:20

  • ... st_output = Invoke-RestMethod -method 'POST' -uri ($ITGlue_Base_URI + ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
      eption
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

@jhill777
Copy link

Did something change? Trying to run the active directory integration on a server that has completed successfully in the past. Getting errors now.

Active Directory flex asset configuration file found!
Exception calling "Add" with "2" argument(s): "An item with the same key has already been added."
At C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI\Resources\Configurations.ps1:90 char:5

  • $ITGlue_Headers.Add('x-api-key', (New-Object -TypeName System.Management.Aut ...
    
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : ArgumentException
    
    

Cannot index into a null array.
At C:\ITGlue\Active Directory\ActiveDirectory.ps1:175 char:5

  • $api__SchemaMaster_id = (Get-ITGlueConfigurations -filter_organization_id $a ...
    
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : NullArray
    
    

Cannot index into a null array.
At C:\ITGlue\Active Directory\ActiveDirectory.ps1:176 char:5

  • $api__DomainNamingMaster_id = (Get-ITGlueConfigurations -filter_organization ...
    
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : NullArray
    
    

Cannot index into a null array.
At C:\ITGlue\Active Directory\ActiveDirectory.ps1:177 char:5

  • $api__RIDMaster_id = (Get-ITGlueConfigurations -filter_organization_id $api_ ...
    
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : NullArray
    
    

Cannot index into a null array.
At C:\ITGlue\Active Directory\ActiveDirectory.ps1:178 char:5

  • $api__PDCEmulator_id = (Get-ITGlueConfigurations -filter_organization_id $ap ...
    
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : NullArray
    
    

Cannot index into a null array.
At C:\ITGlue\Active Directory\ActiveDirectory.ps1:179 char:5

  • $api__InfrastructureMaster_id = (Get-ITGlueConfigurations -filter_organizati ...
    
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : NullArray
    
    

Cannot index into a null array.
At C:\ITGlue\Active Directory\ActiveDirectory.ps1:185 char:9

  •     $tmp_global_catalog_ids[$idx] = (Get-ITGlueConfigurations -filter_organi ...
    
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : NullArray
    
    

No flexible asset id was found... creating a new flexible asset.
Invoke-RestMethod : {"errors":[{"status":401,"title":"Unauthorized","detail":"Unauthorized resource
access","source":{"pointer":"id"}}]}
At C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI\Resources\FlexibleAssets.ps1:12 char:20

  • $rest_output = Invoke-RestMethod -method 'POST' -uri ($ITGlue_Base_URI + $re ...
    
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
     eption
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    

@AHelsby
Copy link

AHelsby commented Jan 19, 2022

Oddly enough I'm getting the same as the original poster for a new client. Works fine at another client and creates and or updates the existing AD flexible asset.
When I try at this client i get
`Active Directory flex asset configuration file found!
No flexible asset id was found... creating a new flexible asset.
New-ITGlueFlexibleAssets : {"errors":[{"status":401,"title":"Unauthorized","detail":"Unauthorized resource
access","source":{"pointer":"id"}}]}
At C:\jobs\ActiveDirectory.ps1:338 char:41

  •                 $api__output_data = New-ITGlueFlexibleAssets -data $api__bod ...
    
  •                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-ITGlueFlexibleAssets`

get-itglueusers, (get-itglueorganizations).data both return valid data.
Same api key is used at each location.

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

No branches or pull requests

6 participants