Forum Discussion

Vee's avatar
11 months ago
Solved

Getting Graph Sharing Token via REST API

Hello,

I am new member of LogicMonior.    I have created new dashboard and done about adding device graph into dashboard via API, it work!      but now, I want to generate “Widget Embedded URL” and also get “Sharing Token” via REST API, after created graph on Dashboard.     Is it possible to do that?

Thank you very much for all recommendation and comment

  • It looks like you’re trying to post in the token. You don’t post in the token, it’ll be in the response.

    Also, add a header called “X-Version” with a value of 3. This ensures you are using API v3 (if you don’t specify it will assume v1 or v2, which might not be backward compatible with a v3 reuqest)..

    You might consider manually creating the token with the developer tools for your browser open. This will let you see on the network tab all the details of the request that are made when the UI makes the call.

14 Replies

  • It looks like you’re trying to post in the token. You don’t post in the token, it’ll be in the response.

    Also, add a header called “X-Version” with a value of 3. This ensures you are using API v3 (if you don’t specify it will assume v1 or v2, which might not be backward compatible with a v3 reuqest)..

    You might consider manually creating the token with the developer tools for your browser open. This will let you see on the network tab all the details of the request that are made when the UI makes the call.

  • Hi  @Stuart Weenig 

    I have got “415Unsupported Media Type” as following detail 

  • Wow, Let me try to do as your recommended. 

    i really appreciate your help thank you very much @Stuart Weenig   :) 

  • It doesn’t appear to be documented, which means it won’t be supported, but you should be able to do it.

    You have to do a POST to /setting/admins/sharingtokens?fields=token

    The payload should consist of the widget id like this:

    {"resourceType":"widget","resourceId":11124,"enable":true,"note":""}

    Where 11124 is the widget id in this case. I think you should be able to post in a note as well. The UI doesn’t prompt for the note when you first create it, but it does allow you to edit it afterward and add the note. Main point: note should be doable, but is optional.