Question

FMESever.runDataDownload() returns Failed to login


Badge
Hello all, I am new to the FME server JavaScript API. Hope I can find some help here. 

What I am doing is pretty straightforward. When I click a button, it fires runDataDownload() and adds a data download link on the web page. But what i got was job failure status with an error "message": "Authentication failed: Failed to login". What did I miss here? Please help. 


<div>
    <input type="button" onclick="runDataDownload()" value="Request data">
</div>

<scirpt>
window.onload = function() {
        FMEServer.init({
            server : "https://demos-safe-software.fmecloud.com",
            token : "568c604bc1f235bbe137c514e7c61a8436043070"
        });
};

function runDataDownload() {
var params = { "publishedParameters" : [ { "name" : 'GEOM', "value" : 'POLYGON((-123.00399475097656 49.32606781005859,-122.9785888671875  49.22444427490234,-123.15643005371093 49.1509732055664,-123.00399475097656 49.32606781005859))' }, { "name" : 'THEMES', "value" :  ['BusRoutes'] }, { "name" : 'COORDSYS', "value" : 'BCALB-83' }, { "name" : 'GENERIC_FORMAT', "value" : 'ACAD' }]
};
FMEServer.runDataDownload('Demos', 'DataDownloadService.fmw', params.publishedParameters, showResults);
}

function showResults( json ) {
var resultText = result.serviceResponse.statusInfo.status;
var resultUrl = '';

var resultDiv = new Builder('<div />');

if(resultText == 'success'){
    resultUrl = result.serviceResponse.url;
    resultDiv.append(('<h2>Job ran sucessfully. Data can be downloaded <a href="' + resultUrl + '">' + 'here </a></h2>'));
}
else{
    resultDiv.append(('<h2>There was an error processing your request. Here is the error message ' + result.serviceResponse.statusInfo.message + '</h2>'));
}

dom.byId('result').innerHTML = resultDiv;
}
</script>

7 replies

Userlevel 3
Badge +17

Hi @wgsl2005, did you check that the FMEServer.init() has logged in successfully?

And the parameter setting might be invalid. The description in the doc: "Any workspace specific parameter values as a string: name1=value1&name2;=value2 etc..."

Badge

Hi @wgsl2005, did you check that the FMEServer.init() has logged in successfully?

And the parameter setting might be invalid. The description in the doc: "Any workspace specific parameter values as a string: name1=value1&name2;=value2 etc..."

thanks for your response. how to check if the FMEserver.init() has logged in successfully? sorry for the newbie question. Any help is truly appreciated.

Userlevel 3
Badge +17

thanks for your response. how to check if the FMEserver.init() has logged in successfully? sorry for the newbie question. Any help is truly appreciated.

@wgsl2005, see the 'fmerserver.log' using the FME Server web interface.

Menu: Manage > Resources | Logs/core/current/fmeserver.log

Badge

@wgsl2005, see the 'fmerserver.log' using the FME Server web interface.

Menu: Manage > Resources | Logs/core/current/fmeserver.log

I am calling demos-safe-software.fmecloud.com. Not sure how I can log in the web interface?

Userlevel 3
Badge +17

I am calling demos-safe-software.fmecloud.com. Not sure how I can log in the web interface?

@wgsl2005, that's the Safe's demo server. Maybe you can not look at the log, and also it depends on the server configuration whether your application can access the server from an external domain. See this page: Cross-Origin Resource Sharing.

Sorry, I cannot resolve your issue. You may have to contact Safe...

Badge

not sure why the params items are not concatenated correctly. it worked after i change the params to a string like 'opt_showresult=true&opt;_servicemode=sync&opt;_responseformat=json&GEOM;=POLYGON((-123.11659746172772 49.26220977783203,-123.02664690020428 49.24367034912109,-123.07059221270428 49.17500579833984,-123.11659746172772 49.26220977783203))&THEMES;=BusRoutes&COORDSYS;=BCALB-83&GENERIC;_FORMAT=ACAD'

Badge +5

For tokens, the question is where did your token come from (if you can't log in how did you generate this?) and do you know that it has not expired? Another question would be, does the user whose token that is have security permission to use the data download service, and more specifically, on workspaces in that repository? I think those are the key issues here.

If you're just testing out some ideas for Server, it is probably better to use http://playground.fmeserver.com/ instead of the demos site. I'm not even sure the demos installation is open to users.

If you still have problems then, yes, please do contact the Safe support team (safe.com/support) and ask for help from the Server team.

Regards

Mark

 

Product Evangelist

 

Safe Software Inc

Reply