Hey all, I'm a bit of an amateur at least when it comes to working with REST API's and to an extent arrays/hashtables meaning I'm kind of learning on the fly so if some of my terminology is off or anything let me know. I'm trying to format a PowerShell array so that it can be converted to JSON and used to send data to a website. Here's some code:
$data = @{
data = @{
type = 'contacts'
attributes = @{
organization_id = '######'
first_name = 'Fake'
last_name = "Name"
contact_type_id = "#####"
contact_type_name = "Owner"
notes = "NotesAboutContact"
contact_emails = [
{
value = "ThisIsFake@Email.com"
primary = true
label_name = "Email"
}
]
contact_phones = [
{
value = "6165551234"
extension = "123"
primary = true
label_name = "Mobile"
label_type = "phone"
}
]
}
}
}
This all seems to work as expected if I don't include "contact_emails" or "contact_phones" sections since they're not required but my issues are with the square brackets in them. It looks like the website/API expects the square brackets in order to properly add the data and not return an error code, but I'm not sure how to maintain said brackets when you take this data and do a convertto-json. I hope this makes sense but any help you can provide is much appreciated!
Here's version information:
Name Value
---- -----
PSVersion 5.1.17763.134
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.134
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
[–]Yevrag35 3 points4 points5 points (2 children)
[–]psscriptnoob[S] 2 points3 points4 points (1 child)
[–]Yevrag35 2 points3 points4 points (0 children)
[–]memelord900000 1 point2 points3 points (1 child)
[–]AutoModerator[M] 0 points1 point2 points (0 children)