8,330 questions
Uploading a file in yammer using the api uploadsmallfile
Anonymous
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?
Windows for business Windows Server User experience PowerShell
Sign in to answer