Uploading a file in yammer using the api uploadsmallfile

Thakur, Harshdeep 0 Reputation points
2023-05-11T09:10:57.6+00:00

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?

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,329 questions
0 comments No comments
{count} votes