itglue / automation

A place for IT Glue's user community to learn ways of automating their documentation.
Apache License 2.0
99 stars 33 forks source link

Internal Server Error #27

Closed IanPennebaker closed 5 years ago

IanPennebaker commented 5 years ago

I am completely lost. Here is my very simple code. ` $data = @{

    type = "flexible-assets"

    attributes = @{

        organization_id = xxxxx #Left out intentionally

        flexible_asset_type_id = xxxxx #Left out intentionally

        traits = @{

            name = "Test"

            location = "Home"

        }

    }

}

$output = New-ITGlueFlexibleAssets -data (ConvertTo-Json $data) `

And here is the error I get: ` New-ITGlueFlexibleAssets : The remote server returned an error: (500) Internal Server Error. At line:1 char:11

Does anyone have any idea? Thanks in advanced.

CalebAlbers commented 5 years ago

Hey @IanPennebaker,

The New-ITGlueFlexibleAssets function already takes care of the JSON conversion for you, so you shouldn't need to use the ConvertTo-Json function. Can you try without it and let me know what response you get? You should just be able to run:

$output = New-ITGlueFlexibleAssets -data $data
IanPennebaker commented 5 years ago

Hey @CalebAlbers

I removed the ConvertTo-JSON and am now getting the following error: `New-ITGlueFlexibleAssets : {"errors":[{"status":401,"title":"Unauthorized","detail":"Unauthorized resource access","source":{"pointer":"id"}}]} At line:12 char:11

Base URI and API Key are correct as I was able to create a new location.

IanPennebaker commented 5 years ago

SOLVED

My "location" field had to take the location ID rather than name.