My goal is to compile a design automation web application using an input file, such as an RVT and Json file. However, I am encountering an issue where I need to pass only a Json file as input for workItem in ForgeDesignAutomation.js. In the code snippet below, it seems that the 'inputFile' needs to be stringified. Can someone please assist me in correcting the syntax?
In this scenario, 'inputFile' refers to a Json file only, with no RVT file being uploaded. My addin requires only a json file as input, which contains an array of strings and returns a rfa file as output.
I am unsure how to stringify the 'inputFile', especially when it is just a .json file.
function startWorkitem()
{
var inputFileField = document.getElementById('inputFile');
if (inputFileField.files.length === 0) { alert('Please select an input file'); return; }
if ($('#activity').val() === null) { alert('Please select an activity'); return };
var file = inputFileField.files[0];
let activityId = $('#activity').val();
if (activityId == null)
{
alert('Please select an activity'); return
};
if (activityId.toLowerCase() === "myfirst_da4ractivity+dev")
{
startConnection(function () {
var formData = new FormData();
formData.append('inputFile', file);
//file is not uploading-------I think I could not pass the Json file.
//I need to pass connection ID here too.
writeLog('Uploading input file...');
$.ajax({
url: 'api/forge/designautomation/workitems',
dataType: 'json',
data: formData,
processData: false,
contentType: false,
type: 'POST',
success: function (res)
{
writeLog('Workitem started: ' + res.workItemId);
}
});
});
}
}