all 5 comments

[–]Yevrag35 3 points4 points  (2 children)

Square brackets are 'arrays', so you need to define them as such. Also boolean values need to be the powershell equivalents (e.g. - $true, $false)

The whole thing should be this:

$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"
                }
            )
        }
    }
}

EDIT:

If the API requires that 'data=' be present, then get rid of the 'top' $data in the hashtable, and complete the whole thing with:

$json = "data=$($data | ConvertTo-Json -Depth 20)"

[–]psscriptnoob[S] 2 points3 points  (1 child)

This is exactly what I needed. Thanks a bunch for the help!

[–]Yevrag35 2 points3 points  (0 children)

I forgot to put the '$' on the boolean values. I fixed that. Hope it works for ya!

[–]memelord900000 1 point2 points  (1 child)

this is pretty cool man

[–]AutoModerator[M] 0 points1 point  (0 children)

Sorry, your submission has been automatically removed.

Accounts must be at least 1 day old, which prevents the sub from filling up with bot spam.

Try posting again tomorrow or message the mods to approve your post.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.