There was an issue when attempting to upload a single JSON file as input for the workitem in DesignAutomation

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);
            }
        });
    });
}

}

Answer №1

Based on your inquiry, you are dealing with a scenario where a client submits data to your server, which in turn forwards it to Forge.

When sending data to the

api/forge/designautomation/workitems
endpoint, the format will depend on the expected input. If you have a .json file, you do not need to stringify it as it is passed as a file. However, if you choose to send it as data, then you should stringify it and adjust the format to data: { your JSON data here },

If the JSON file originates from your client and reaches your server, you can then submit that file to Forge as an input for your Workitem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Create a mobile-friendly version of the clndr.js calendar

I am currently using a calendar created with the CLNDR plugin, which is quite impressive as it leverages underscore.js and moment.js. While the calendar functions perfectly, I am facing an issue in making it responsive for screens of varying sizes. Despite ...

"MongoDB Reveals Its True Power: Unveiling the Second

I am facing an issue with the second res.json. I have attempted the following: res.json({500,message : 'xxxxxx'}) res.send({500,message : 'xxxxxx'}) However, the problem persists. Here is my code snippet: import mongoose from ' ...

Unexpected bug encountered while implementing redux

I received a warning from eslint while working with create-react-app. ./src/components/auth.js Line 24: Unexpected labeled statement no-labels Line 24: 'authenticated:' is defined but never used ...

Navigating through multi-layered JSON arrays/objects with PHP

I am facing a challenge looping through a local JSON file in PHP to access specific information. My goal is to extract the coordinates for each country and store them in a new array, where the country name serves as the key and the coordinates act as the v ...

Conditional Update with Primefaces p:ajax Event Listener

Using JSF to update client ids: <p:commandButton> <p:ajax process="@this" update="name desc msg" listener="#{bean.deleteListener}"/> </p:commandButton> Here's how the Bean handles the logic: public void deleteListener() { ...

Interactive quiz program based on object-oriented principles

As I work on developing a quiz app using JavaScript, everything seems to be going well. However, I've encountered an issue with validation where my code is validating the answers twice - once with the correct answer from the previous question and agai ...

Performing a JSON GET request in Python is similar to using cURL

I have a command using cURL that I want to convert into Python. curl -XGET "http://localhost:9200/nuix-7674bc4a60b74ea7bac8996a98b0cb94;item;schema-version=1/_search" -H 'Content-Type: application/json' -d' { "query": { "regexp": { ...

"Learn the process of incorporating a trendline into a line chart using Highcharts by manipulating the

I am facing difficulties in creating a trend line for a line chart. I have tried some old solutions but they did not work for me. Below is my current code: { "key": "003", "title": "Detections", "ty ...

Creating an interactive accordion table using vue.js and the v-for directive in the main element

Looking for some help on implementing this feature using VUE: https://jsfiddle.net/jacekpr/roschwvL/5/ Currently, my progress is here: https://jsfiddle.net/jacekpr/8bhpqc5s/13/ However, I'm facing an issue with having multiple root elements in the ...

Ways to stop the Kendo Panelbar from collapsing upon clicking a button on the panelbar

My challenge involves a button placed on a Kendo Panelbar. I attempted to create a jQuery function to prevent the panelbar from collapsing when the button is clicked, as well as to avoid any post-back action. Unfortunately, my code isn't working as ex ...

Vessel + AngularJS - CORS rejection in action

Snippet: @route('/characteristicsToBestWeb', method='OPTIONS') def respondToCharToBestQueryWebOptions(): response.headers['Access-Control-Allow-Origin'] = settings.allowed_web_origin response.headers['Access-Cont ...

Issue encountered while appending new rows to the tbody of a table

I'm encountering an issue with the append function within a for loop in my code. The string being passed to the function isn't parsing correctly and results in an error. How can I go about resolving this problem? Thanks! function getDetailPopUp ...

define` module root path

Currently, I am working with Typescript and my source files are located in the src directory. After transpiling, Typescript generates the output in the lib folder. This means that when I need to import components from my package, I have to specify the full ...

Using Ajax to query CodeIgniter's model with a post variable and get results with the `

Initially, let's say I want to retrieve a record with the primary key 'customer_code' 4 and display it in a form. I have successfully achieved this using a simple function in the model: public function get_Acustomer() { $query = $ ...

Concealing numerous tables depending on the visibility conditions of subordinate tables

I have the following HTML code which includes multiple parent tables, each with a specific class assigned to it: <table class="customFormTable block"> Within these parent tables, there are child tables structured like this: <table id="elementTa ...

Adjustable Scroll Bar

Could anyone help me find a component similar to the resizable scrollbar on Google Finance? Check out this link: http://www.google.com/finance?q=EURUSD&ei=bhM_UKDXF-aIWqAPVNQ You can see it below the chart. If you know where I can find something like ...

Accessing a variable that was declared inside a promise in Protractor can be achieved by

In my current scenario, I need to access the result of a promise variable at a global level or outside of its scope. var mobileNumber = database.generateMobileNumber().then(function(number) { return number; // The 'number' variable needs to be a ...

E/Volley: [126] BasicNetwork.performRequest: Received an unexpected HTTP error with code 500

Why do I get the error "E/Volley: [126] BasicNetwork.performRequest: Unexpected response code 500" when I click on the "login" button? Note: It works locally with a local database. This is my code: config.java: public class Config { //URL to our lo ...

stop all HTML5 videos when a specific video is played using jQuery

I am facing an issue with 10 HTML5 videos on the same page, CHALLENGE Whenever I click on different videos, they all start playing simultaneously... <div><video class="SetVideo"></video><button class="videoP"></button>< ...

Transform information into a json structure

import enum import requests from bs4 import BeautifulSoup import json import pandas as pd headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.3" ...