Solved

Correct way to override default value in published parameters when running workspace from Javascript API.

  • 3 November 2021
  • 1 reply
  • 1 view

Badge

Getting back to my little project started here after a brief hiatus...

 

I am having trouble making a file uploaded to the 'Resources' folder using the Javascript API the input for a workbench.

 

Using ...

FMEServer.dataUpload( repository, workspace, fileObject, session, callback);

I can get the file to be uploaded to here:

$(FME_SHAREDRESOURCE_TEMP)/upload/MyFolder/MyWorkspace.fmw/

Now, I want to use:

FMEServer.runWorkspaceWithData( repository, workspace, params, callback)

to process the uploaded file but all attempt to feed in the correct 'params' is failing. The workspace is still going back to the default parameters that it was published with.

 

Currently, I'm trying this:

var params = {          
{ "publishedParameters" : [{ "name" : 'SourceDataset_CSV2', "value" : <resourceFolderPath+inputFileName >},
{ "name" : 'DestDataset_JSON', "value" : < ?????>}],
 
 "service" : "fmedatastreaming"
 };

Not sure  what to put for the destination value that I'm trying to capture. Javascript API documentation shows something like this and I have tried it as well:

params = { filename : workspace_file_parameter_name,
files : files_object,
params : name_value_pair_string,
service : service_name }

I feel like I'm not seeing the forest for the trees. If you have an example of how you would accomplish this, I'd love to see it.

  1. Upload a file to resources => Working
  2. Reference that uploaded file as input for Source published parameter when running workspace.

Thanks.

 

 

icon

Best answer by agelfert 10 November 2021, 23:36

View original

1 reply

Badge

Seems like this was a combination of using the wrong method and overthinking the parameters. Turns out there is a dedicated method in the API for getting output streamed:

FMEServer.runDataStreaming( repository, workspace, parameters, callback )

Documentation here: https://playground.fmeserver.com/

 

And the params can be as simple as:

parameters = "SourceDataset =  " + "<path to data uploaded to resource folder>"+"&"+"DestDataset = <unused>";
 
// unused is needed even if it's unused !

Based on using a simple string rather than stringified JSON 

params = "name1=value1&name2=value2"

Everything is working! Yeah!

 

Reply