PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,329 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to upload a file using the yammer api endpoint "**https://www.yammer.com/api/v4/uploadsmallfile.json**"
Below Script I am using:
# Set the URI of the REST endpoint
$uri = "https://www.yammer.com/api/v4/uploadsmallfile.json"
# Set the path of the file to upload
$file = "C:\Temp\image.png"
# Set the access token for authorization
$accessToken = "my access token"
# Create a header for authorization
$header = @{
Authorization = "Bearer $accessToken"
}
# Create a body with the file data
$body = @{
file = Get-Content $file -Encoding Byte
}
# Upload the file using Invoke-RestMethod
$response = Invoke-RestMethod -Uri $uri -Method Post -Headers $header -Body $body
# Print the response from the API
Write-Output $response
It is giving me 404 error. Can somebody help me to find out what I am missing here?