// Upload the file to the newly created Track record function uploadFile(fileContent,fileName,entityID) { var record = {}; record.musdyn_name = fileName; webapi.safeAjax({ type: "PUT", // NOTE: right now Portals requires PUT instead of PATCH for the upload url: "/_api/musdyn_tracks(" + entityID + ")/musdyn_audiotrack?x-ms-file-name=" + fileName, contentType: "application/octet-stream", data: fileContent, processData: false, success: function (data, textStatus, xhr) { // Provide some visual feedback re successful upload $('#upload-Audio h1').html('<span style="color: #1ed760;" class="glyphicon glyphicon-ok"></span> Here\'s your audio'); // Set the source of the hidden audio player audioPlayerSrcURL = '/File/download.aspx?Entity=musdyn_track' + '&Attribute=musdyn_audiotrack&Id=' + entityID; $('#upload-player').attr('src',audioPlayerSrcURL) // Show the audio player $('.showOnSuccess').slideDown(200); // Hide the form $('#track-content').slideUp(200); }, error: function (xhr, textStatus, errorThrown) { // If error occurs uploading the file, provide visual feedback $('#upload-Audio h1').text('Uh oh, uploading file the track'); } }); }