Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created September 4, 2024 10:51
Show Gist options
  • Save AlexanderHolmeset/e34cea58bd63a3bfae350bb5520ae5fe to your computer and use it in GitHub Desktop.
Save AlexanderHolmeset/e34cea58bd63a3bfae350bb5520ae5fe to your computer and use it in GitHub Desktop.
$bearerToken = "Enter Token"
$Headers = @{ Authorization=("Bearer " + $bearerToken) }
$CommunityName = "Demo"
$Private = "false"
$CreateCommunity = Invoke-RestMethod –Uri "https://www.yammer.com/api/v1/groups.json?name=$CommunityName&private=$Private" –Method Post -Headers $headers
$body = @"
{
"body": "Original message posted by Kari Nordmann - 19.062023 16:45
This is the old message. Im just testing the Yammer API to see whats possible.",
"group_id" : $($CreateCommunity.id)
}
"@
$CreateMessage = Invoke-RestMethod –Uri "https://www.yammer.com/api/v1/messages.json" –Method Post -Headers $headers -Body $body -ContentType "application/json"
$body = @"
{
"body": "Original message posted by Ola Nordmann - 20.06.2023 08:45
This is a reply.",
"replied_to_id": "$($CreateMessage.messages.id)"
}
"@
$CreateReply = Invoke-RestMethod –Uri "https://www.yammer.com/api/v1/messages.json" –Method Post -Headers $headers -Body $body -ContentType "application/json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment