Skip to main content

RestUtility does not add token to url

Comments

5 comments

  • Berend Veldkamp

    Hi Alejandro,

     

    Thanks for that. The 2nd parameter of getCustomRestEndpoint should be a string though, so I guess it would have to be something like this "token={0}".format(this.myToken) ? BTW, isn't the RestUtility supposed to add the token by itself?

     

    One more question: I can get the token by listening to the AuthenticationSucceeded event, but what happens if that token expires? Will the system automatically generate a new token and raise the event again ? (What's the expiration time anyway?)

    0
  • Berend Veldkamp

    I think the definition for getCustomRestEndpoint() in essentials.d.ts is not correct. The 2nd parameter is defined as a string:

    public getCustomRestEndpoint(endpointUrl: string, content: string , completeHandler: (res: essentials.RestEndpointResult) => void, errorHandler: (error: Error) => void, options: Object): void;

    but is handled as an object. For example, I can't pass { "abc": "xyz" } to it ('Supplied parameters do not match any signature of call target'), but if I pass "abc=xyz", the parameters in the url look like &0=a&1=b&2=c&3=%3D&4=x&5=y&6=z&.

     

    What works now is to just ignore the 2nd param, and add any param to the url directly:

    restUtility.getCustomRestEndpoint("{0}&token={1}".format(url, this.myToken), "", (result: geocortex.essentials.RestEndpointResult) => { ...

     

    0
  • Permanently deleted user

    I had that exact same issue, I just went into the d.ts file and changed the defiinition to content: any so I could pass in a dictionary of values

    That's the way it was defined in the 5.1 api or so, it changed recently to content:string, not sure why.

    0
  • Permanently deleted user

    (version number off), somewhere like 2.1 => 2.3 

    0
  • Berend Veldkamp

    Hi Alejandro,

    Thanks for the clarification, it does make sense to not include the token automatically. I think I got confused by the similar method in the SL viewer, which does that. At least, IIRC.

    Berend

    0

Please sign in to leave a comment.