function createFile() { var record = {}; // Get the name from the form field and escape any special characters record.musdyn_name = encodeURIComponent(trackName); $('#upload-Audio h1').text('Uploading...'); webapi.safeAjax({ type: "POST", url: "/_api/musdyn_tracks", contentType:"application/json", data: JSON.stringify(record), success: function (data, textStatus, xhr) { // If record creation succeeds, get the GUID of the newly created record and store in a varibale for easy reuse var entityID = xhr.getResponseHeader("entityid"); // Provide some visual feedback re success of this stage $('#upload-Audio h1').text('Track created, uploading audio file'); // Run the getFileContentsAndMetadata function, passing the GUID of the newly created record getFileContentsAndMetadata(entityID); }, error: function (xhr, textStatus, errorThrown) { // If the creation fails, provide some visual feedback $('#upload-Audio h1').text('Uh oh, error creating the track'); } }); }