Question

A callback function must be defined in order to use the FME Server REST API.

  • 19 February 2019
  • 1 reply
  • 1 view

Hello

I have tried to replicate one demo application from FME Server Playground. I have replaced repository name and workspace name and initialized my FMEServer with my host and token values. As can be seen from the screenshot after modifications, the HTML page opens correctly, and I am receiving works parameters. “Choose File” and “Upload Files” buttons do they work but after hitting “Run Works Space With Data” I getting an error. Can you please help me to fix this issue?


1 reply

Badge +9

Hello @linasster,

I'm sorry you are encountering an issue with recreating the demo. A callback is a function that needs another function to occur first before it can be used. So, chances are that the function behind "Run Workspace with Data" doesn't have a callback function defined in the function.

The runWorkspace function should look like this:

function runWorkspace()
{
    if (files != undefined || archives != undefined)
    {
        if (archives != undefined)
        {
            files = archives;
        }
        setWorkspace();

        var params = {
            filename: fileInput.name,
            files: files,
            params: processParams()
        }
        // Ask FME Server to run the workspace with the uploaded data
        FMEServer.runWorkspaceWithData(path, params, showResults);
    }
    else
    {
        alert("No Files Uploaded.  Please upload a file.");
    }
}

Further, in your code, there should be a showResults function which is the callback. If you would like you can include your code (without your server or token) and I can try identifying where the issue is. Or you can follow this exercise to build the same example:

 

 

https://s3.amazonaws.com/gitbook/Server-REST-API-2018/FMESERVER_RESTAPI9CustomApplications/9.8.ExerciseUpload.html 

 

Kind Regards,

Sienna

Reply