Question

FME Server: How to generate new session ID via REST API?


Badge +1

Hello everybody,

I´m trying to solve problem with using REST API on FME Server. All I need is to generate new session ID for every data upload to FME server. Is there any special function to generate new session ID?

Now, if I upload new datafile, the FME Server still keeps the same session ID, e.g.:

{"serviceResponse": {

"statusInfo": {"status": "success"},

"session": "DDDB81451D5F0192DE8292DD71A0EF46",

"files": {

"path": "",

"folder": [{"name": ""}]

}

}}

I tried to use getSession function (meant there: https://knowledge.safe.com/questions/57605/javascript-rest-example-keeps-sessionid.html) but i doesnt work, because it returns still the same session ID. How to generate new one please?

Thank You so much for all tips!

Lubo


11 replies

Userlevel 2
Badge +17
The behavior regarding Session ID could be different depending on FME Server version and FMEServer.js library version. Could you please clarify those versions?

 

 

Badge +1
The behavior regarding Session ID could be different depending on FME Server version and FMEServer.js library version. Could you please clarify those versions?

 

 

Hello @takashi,

 

 

I use following version: FME Server 2017.1.2.1 - Build 17725 - win64 and appropriate FMEServer.js.

 

Userlevel 2
Badge +17
The behavior regarding Session ID could be different depending on FME Server version and FMEServer.js library version. Could you please clarify those versions?

 

 

Thanks for the input. Using FME Server 2017.1.2.1, I think the FMEServer.getSession method should generate unique setting ID for each call. In this case, it's hard to know where the issue is unless you can share the JavaScript code with us.

 

Badge +1
Thanks for the input. Using FME Server 2017.1.2.1, I think the FMEServer.getSession method should generate unique setting ID for each call. In this case, it's hard to know where the issue is unless you can share the JavaScript code with us.

 

I´m calling this one:

 

http://XXX:8080/fmedataupload/Conversion DGN (V7) - TXT XML/dgn2txtxml.fmw?opt_extractarchive=false&opt;_pathlevel=3&opt;_fullpath=true&token;=65317d1c5119db062858bc80ee7d269ce2daa5cf through post and get method, but everytime we will get the same sesion ID :-(

 

 

Userlevel 2
Badge +17
The behavior regarding Session ID could be different depending on FME Server version and FMEServer.js library version. Could you please clarify those versions?

 

 

I think the description in the "Preserving Session State" section here could help you.

 

FME Server Documentation >> Data Upload Service

 

However, I'm unclear why the FMEServer.getSession method didn't work for you. How did you confirm that the method always returen the same Session ID?

 

Badge +1
I think the description in the "Preserving Session State" section here could help you.

 

FME Server Documentation >> Data Upload Service

 

However, I'm unclear why the FMEServer.getSession method didn't work for you. How did you confirm that the method always returen the same Session ID?

 

Hello @takashi,

 

 

I attached video below, which should make it clear. I´m calling dataupload service according to library FMEServer.js specifications. If I open web browser - I will get session ID. If I open new tab in the same browser - I will get same session ID. Even if I reload the same page, I will get the same session ID. Only way to generate new session ID is to close web browser completely and open it again. What I need is to generate new session ID even during recalling of this link (http://XXX:8080/fmedataupload/Conversion%20DGN%20(V7)%20-%20TXT%20XML/dgn2txtxml.fmw?opt_extractarchive=false&opt;_pathlevel=3&opt;_fullpath=true&token;=3294ba73b6202c63c6930c5e29c4191cdf000622) - e.g. situations, when I reload the page or open new tab in web browser. Is there any function to do that please?

 

 

session-id.mp4

 

 

Thank You so much!

 

Lubo
Userlevel 2
Badge +17
The behavior regarding Session ID could be different depending on FME Server version and FMEServer.js library version. Could you please clarify those versions?

 

 

Looks like the browser preserves the Session ID in some condition.

 

Then, how did you apply the workaround described in this thread you have linked?

 

Javascript Rest example keeps sessionID

 

 

Badge +1
Looks like the browser preserves the Session ID in some condition.

 

Then, how did you apply the workaround described in this thread you have linked?

 

Javascript Rest example keeps sessionID

 

 

@takashi, unfortunately, didnt apply, because I need to generate new session ID just through REST API calling... IS there any possibility to get it please?

 

Badge

@lazarlubomir,

which version of the FME Server JS API are you using?

With your version of FME Server (Build 17725) you should use the version v1.1. Please be aware that our examples on the FME Server Playground we are using version v1.2. because they run on the newest version of FME Server.

Let me know if this helps.

Badge +1

Hello @GerhardAtSafe,

unfortunately, It doesnt help me... We just tested this call via web browser, but finally, we can´t use JavaScript and we will not call this link via web browser, but we will call it from another application (customized for customer) based on another technology. Is it problem? Is there any possibility to generate new Session ID via this call from another application without using javascript?

Badge

Hello @GerhardAtSafe,

unfortunately, It doesnt help me... We just tested this call
via web browser, but finally, we can´t use JavaScript and we will not call this
link via web browser, but we will call it from another application (customized
for customer) based on another technology. Is it problem? Is there any
possibility to generate new Session ID via this call from another application
without using javascript?

Hi @lazarlubomir,

 

you can create a new session ID by sending a POST request to the data upload service. This is basically what the FMEServer.getSession JS function does:

 

getSession : function(repository, workspace, callback){
            callback = callback || null;
            var url = buildURL('{{svr}}/fmedataupload/' + repository +       '/' + workspace);
            var params = 'opt_extractarchive=false&opt;_pathlevel=3&opt;_f ullpath=true&token;=' + getConfig('token');
            ajax(url, callback, 'POST', params, 'application/x-www-form- urlencoded');
}
 I the video you previously shared you are sending GET requests to the data upload service which only returns the current session. A POST request will renew the session if no jsid is specified.

 

The JS API is just a wrapper for a couple of REST API, data upload, data streaming and data download requests.

 

Please also check the documentation for the Data Upload service.

 

Cheers,

 

Gerhard

 

Reply