Audio object

The Audio object contains info about a user's audio in Microsoft OneDrive.

The Live SDK REST API supports creating, reading, updating, and deleting Audio objects.

Use the wl.skydrive scope to read Audio objects. Use the wl.contacts_skydrive scope to read any audio that other users have shared with the user. Use the wl.skydrive_update scope to create, update, or delete Audio objects.

Valid object paths

  • /AUDIO_ID

An Audio object can be returned as part of /ALBUM_ID/files, /FOLDER_ID/files, /me/skydrive/files, or USER_ID/skydrive/files.

Structures

The Audio object contains the following structures.

Structure

Type

R/W

Description

data

array

R

An array of Audio objects, if a collection of objects is returned.

id

string

R

The Audio object's ID.

from

object

R

Info about the user who uploaded the audio.

name (from object)

string

R

The name of the user who uploaded the audio.

id (from object)

string

R

The ID of the user who uploaded the audio.

name

string

RW

The name of the audio. Required.

description

string/null

RW

A description of the audio, or null if no description is specified.

parent_id

string

R

The id of the folder in which the audio is currently stored.

size

number

R

The size, in bytes, of the audio.

upload_location

string

R

The URL to use to upload a new audio to overwrite the existing audio.

comments_count

number

R

The number of comments associated with the audio.

comments_enabled

true/false

R

A value that indicates whether comments are enabled for the audio. If comments can be made, this value is true; otherwise, it is false.

is_embeddable

true/false

R

A value that indicates whether this audio can be embedded. If this audio can be embedded, this value is true; otherwise, it is false.

source

string

R

The URL to use to download the audio from OneDrive. Important: This value is not persistent. Use it immediately after making the request, and avoid caching.

link

string

R

A URL to view the item on OneDrive.

type

string

R

The type of object; in this case, "audio".

title

string

RW

The audio's title.

artist

string

RW

The audio's artist name.

album

string

RW

The audio's album name.

album_artist

string

RW

The artist name of the audio's album.

genre

string

RW

The audio's genre.

duration

integer

R

The audio's playing time, in milliseconds.

picture

string

R

A URL to view the audio's picture on OneDrive.

shared_with

object

R

The object that contains permission info.

access (shared_with object)

string

R

Info about who can access the audio. The options are: People I selected, Just me, Everyone (public), Friends, My friends and their friends, and People with a link. The default is Just me.

created_time

string

R

The time, in ISO 8601 format, at which the audio was created.

updated_time

string

R

The time, in ISO 8601 format, at which the audio was last updated.

Examples

The following is an example of a collection of Audio objects. (For brevity, only the first object is shown.)

{
   "data": [
      {
         "id": "file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!144", 
         "from": {
            "name": "Stig Struve-Christensen", 
            "id": "a6b2a7e8f2515e5e"
         }, 
         "name": "SampleAudio.mp3", 
         "description": null, 
         "parent_id": "folder.a6b2a7e8f2515e5e", 
         "size": 8414449,
         "upload_location": "https://apis.live.net/v5.0/file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!144/content/",  
         "comments_count": 0, 
         "comments_enabled": false, 
         "is_embeddable": false, 
         "source": "http://storage.live.com/s1p60U8Xs4UzIXTScrTioalE-ZaVFiDQBA15MS2BwcsuNjfG64Z2fw-DAjXnPuqC47YR40_xAoPD8aRGhtna9ZFZ9_oO4BTz4CWF973DTXMxc5U3TntcQ9qEA/SampleAudio.mp3:Binary", 
         "link": "https://skydrive.live.com/redir.aspx?cid\u003d22688711f5410e6c\u0026page\u003dview\u0026resid\u003d22688711F5410E6C!582\u0026parid\u003d22688711F5410E6C!581",
         "type": "audio",
         "title": "My Sample Audio",
         "artist": "My Favorite Artist",
         "album": "My Favorite Album",
         "album_artist": "My Favorite Artist", 
         "genre": "Easy Listening", 
         "duration": 225000,
         "picture": "https://storage.live.com/items/A6B2A7E8F2515E5E!144:MobileReady/SampleAudio.mp3?psid=1&ck=0&ex=720"   
         "shared_with": {
            "access": "Just me"
         }, 
         "created_time": "2012-09-23T22:00:57+0000", 
         "updated_time": "2012-09-03T22:00:57+0000"
      }, {
         ...
      }
   ]      
}

To create a new Audio resource, you can make either a PUT request with the audio in the body or a POST request with the audio in a multipart form body. For POST, make a POST request to the /UPLOAD_LOCATION for the target folder, or a POST request to /FOLDER_ID/files. You must format the request as a multipart/form-data media type as described in RFC 2388. You must specify the Content-Type as multipart/form-data, and specify the boundary like this.

Content-Type: multipart/form-data; boundary=AaB03x

Provide the item to upload on a multipart section, and the name of the audio as the value of the filename parameter of the Content-Disposition header, as shown here.

Note

The boundary value (shown here as "AaB03x") can be any arbitrary string value.

Content-Type: multipart/form-data; boundary=AaB03x
--AaB03x
Content-Disposition: form-data; name="file"; filename="SampleAudio.wav"
Content-Type: audio/mp3

...contents of SampleAudio.wav...
--AaB03x--

Only one multipart section per request is supported. For a PUT request, leave the Content-Type blank and put the contents of the file in the request body.

Upon successful creation, the location header points to the location for the newly created audio, and the response body contains the following properties.

{
   "id": "ID of the new audio",
   "name": "The file's name and file extension",
   "source": "URL where the audio can be downloaded from"
}

You can upload an audio to an existing resource in any of the following ways.

  • Make a PUT request to /UPLOAD_LOCATION/FILE_NAME for the folder you would like to upload to.

  • Make a PUT request to /FOLDER_ID/files/FILE_NAME.

  • Make a PUT request to /ALBUM_ID/files/FILE_NAME.

  • Make a PUT request to /UPLOAD_LOCATION for the file to update.

  • Make a PUT request to /AUDIO_ID/content.

To update the properties for an Audio resource, make a PUT request to /AUDIO_ID, and specify the changes in the request body, as shown here.

{
   "name": "SampleAudioChanged.wav"
   "description": "Holiday Concert"
}

To delete an audio, make a DELETE request to /AUDIO_ID.

To move an audio, make a MOVE request to /AUDIO_IF or /FOLDER_ID, and specify the ID of the destination folder in the request body, as shown here.

{
   "destination": "FOLDER_ID"
}

To copy an audio, make a COPY request to /AUDIO_ID or /FOLDER_ID, and specify the ID of the destination folder in the request body, as shown here.

{
   "destination": "FOLDER_ID"
}

For PUT and POST requests, you can use the overwritequery string parameter to indicate whether the request should fail if the resource already exists, as shown here. Optionally you can specify an overwrite query-string parameter value of ChooseNewName if you want to upload a duplicate copy of the file but let OneDrive choose the uploaded file's new file name. Note that MOVE and COPY do not support overwriting at this time.

If the value of the overwritequery string parameter is set to true, and the audio exists, it is overwritten. If the value is set to false, the audio is not overwritten, and a resource_already_exists error is returned. If no overwritequery string parameter is specified, the default value is true.

overwrite=true
overwrite=false
overwrite=ChooseNewName

See also

REST objects