json payload for teams graph api Invoke-RestMethod RRS feed

  • Question

  • Dear all,

    i try to create create the required json payload for creating a MS teams via graph api as described here:


    However i try to create the json it's always a little bit differently compared to the documented requirement and therefore the Invoke-RestMethod fail:

    Invoke-RestMethod : The remote server returned an error: (400) Bad Request.

    Does someone please have a powersholl code example how to create this json?

    I try:

    $membersettings = @()
    $membersettings += @{allowCreateUpdateChannels= "true"}
    $messagesettings += @{allowUserEditMessages= "true"}
    $messagesettings += @{allowUserDeleteMessages= "true"}
    $funSettings = @()
    $funSettings += @{allowGiphy= "true"}
    $funSettings += @{giphyContentRating= "strict"}

    $body = New-Object -TypeName PSOBject -Property @{
    membersettings = $membersettings
    messagesettings = $messagesettings
    funSettings =$funSettings

    ConvertTo-Json -InputObject $body

    that results in the json: (which fails):

        "funSettings":  [
                                "allowGiphy":  "true"
                                "giphyContentRating":  "strict"
        "messagesettings":  [
                                    "allowUserEditMessages":  "true"
                                    "allowUserDeleteMessages":  "true"
        "membersettings":  [
                                   "allowCreateUpdateChannels":  "true"

    Thank you!

    Friday, January 11, 2019 4:13 PM

All replies

  • The result you posted is valid JSON object formatting.  What is your full Invoke-Restmethod call?
    Friday, January 11, 2019 4:58 PM
  • Try this:

    $membersettings = @{allowCreateUpdateChannels= "true"}
    $messagesettings = @{allowUserEditMessages= "true"; allowUserDeleteMessages= "true"}
    $funSettings = @{allowGiphy = "true"; giphyContentRating = "strict"}

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Friday, January 11, 2019 7:55 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Just do it.

    Tuesday, January 22, 2019 7:34 AM