共用方式為


Upload Files into Yammer - Post

Definition

https://filesng.yammer.com/v4/uploadSmallFile

Parameters

Name In Required Type Description
network_id body yes long Your Yammer Network's ID
target_type body yes string The type of upload, specify GROUP or PRIVATE_MESSAGE. If uploading to All Company group that has 'company' as the group feed id specify ALL_COMPANY or for networks that have a numeric feed id for All Company group specify GROUP. No other target type is acceptable.
filename body yes string UTF8 name of the file being uploaded
file body yes file File that needs to be uploaded into Yammer. Max file size is 4MB
fileid body long 1. absent for a new file, 2. The id of an existing file for version upload
group_id body integer Yammer Group ID where the file needs to be uploaded. This field should not be present if the file is being uploaded to Private Messages. This field should also not be present if the file is being uploaded to All Company group for networks that have 'company' as the feed id for their All Company group. For networks with a numeric feed id for All Company group specify the Group ID.
thread_id body string ID of the Yammer thread to which this file needs to be attached. This field should not be present if the file is a non-thread attachment. Providing the thread_id will not attach the file to the message, it will just upload to the group. Use POST messages.json API to attach the file to the thread.

Documentation

This API enables file upload into a Yammer group. The request should be in a multipart/form-data request format. An Azure Active Directory (AAD) token is required for uploading files into an Office 365 Connected Yammer Group. Upload file size limit is 4MB.

Where uploaded files are stored?

If your Yammer network is enabled with Files in SharePoint, then uploaded files to Office 365 Connected Yammer Groups are stored in SharePoint.

If your Yammer network is not enabled with Files in SharePoint, then all files uploaded using this API will be stored in Yammer cloud storage.

Target_type File storage location
ALL_COMPANY If your All Company group is connected then new files for Office 365 connected groups are stored in the SharePoint document library for the group. They are visible in the Yammer group's Files list, or from the Apps/Yammer folder in the group's SharePoint document library. If your All Company group is not connected then files remain in Yammer cloud storage.
PRIVATE_MESSAGE Uploaded into Yammer cloud storage
Yammer GROUP (Office 365 Connected) Uploaded into SharePoint storage dedicated to that group
Yammer GROUP (Unconnected) Uploaded into Yammer cloud storage

API responses

Response Reason
201 CREATED Occurs when file is successfully uploaded into Yammer
400 BAD REQUEST a) NoFilenameProvided Occurs when no filename is provided (which is a required parameter). (b) NoNetworkIdProvided Occurs when no network id is provided (which is a required parameter). (c) NoTargetTypeProvided Occurs when no target type is provided (which is a required parameter). (d) InvalidTargetTypeProvided Occurs when the target type provided is not a valid one (not ALL_COMPANY, PRIVATE_MESSAGE, or GROUP). (e) NoFileProvided Occurs when no file is attached (which is required). (d) InvalidTargetTypeGroupIDPair Occurs when target_type is selected as GROUP, but no GROUP_ID is included. Or, when target_type is ALL_COMPANY (or PRIVATE_MESSAGE), and a GROUP_ID is included. (e) InvalidFilename Occurs when the filename has invalid characters, e.g., "*:<>?|/\ The recommendation is to rename the file and try the upload again.
500 SERVER ERROR Occurs when the required fields are not included
401 UNAUTHORIZED Occurs when no valid authentication is provided
403 FORBIDDEN OneDriveForbidden Occurs when the upload happens in an Office 365 Connected Yammer Group, but the user does not have permissions in SharePoint to upload the file. For example, if the group is private and the user is not a member of the group
404 NOT_FOUND OneDriveNotFound Usually occurs in scenarios where an Office 365 Connected Yammer Group has just been created and resources have not been provisioned yet. The recommendation is to try the upload at a later time.
409 CONFLICT OneDriveConflict Occurs when another user has uploaded a file with the same name at the same time. The recommendation is to try the upload at a later time
415 UNSUPPORTED MEDIA TYPE NetworkFileUploadMediaOnly Occurs when the network has set up a policy that allows only media files (images and videos), but the user tries to upload a different file type
429 TOO MANY REQUESTS OneDriveTooManyRequests Occurs when too many requests happen at the same time. The recommendation is to try the upload at a later time.
500 SERVER ERROR Occurs for server-related failures.