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
Vee
Posted 3 years ago·Last reply 2 years ago
14 comments
LM User
·2 years agoThat’s odd then. If you look at the dashboard and for the dashboard (at the top right) you select “Default timeframe” do the widgets all show the proper timeframe?
Vee
OP2 years agoYou mean, you edited each widget to have a different default timeframe? That is what I’m suggesting. If that doesn’t work, i’m not sure what to try next.
Do you mean that you made a different dashboard and selected a different timeframe at the top of the dashboard? That won’t work. The timeframe selected at the top of the dashboard has no impact on the configuration of the widget, which is what is used when the widget is displayed externally.
ํYes, I have created each widget to have a different default timeframe and put into dashboard, Then I create sharing widget via API as you guide me.
LM User
·2 years agoYou mean, you edited each widget to have a different default timeframe? That is what I’m suggesting. If that doesn’t work, i’m not sure what to try next.
Do you mean that you made a different dashboard and selected a different timeframe at the top of the dashboard? That won’t work. The timeframe selected at the top of the dashboard has no impact on the configuration of the widget, which is what is used when the widget is displayed externally.
Vee
OP2 years agoIt looks like sharing a widget only allows you to share the widget with the default timeframe configured in the widget. Probably the easiest would be to create a dashboard with the different timeframes you want and generate a sharing token for each one.
You might be able to generate the sharing token, reconfigure the widget to a different default timeframe, and then generate another sharing token. But i’m not sure that would work. Both tokens would probably end up pointing to the same timeframe since the timeframe is in the widget not in the token.
Thank you very much for your quicks help, Before posting, I have already created a dashboard with different timeframes, but I still got the same result (time-range still be 7 days)
Anyway, I will try to do it again as your recommendation. Thank you very much Mr. @Stuart Weenig
LM User
·2 years agoIt looks like sharing a widget only allows you to share the widget with the default timeframe configured in the widget. Probably the easiest would be to create a dashboard with the different timeframes you want and generate a sharing token for each one.
You might be able to generate the sharing token, reconfigure the widget to a different default timeframe, and then generate another sharing token. But i’m not sure that would work. Both tokens would probably end up pointing to the same timeframe since the timeframe is in the widget not in the token.
Vee
OP2 years ago็Hi, @Stuart Weenig Thanks for helping me to create sharing token last time. I have found that “common.timerange” is always be “7days” when created sharing-widget via API with differently timescale)
I am not sure that Is it possible to set “common.timerange” of sharing-widget (like 3months, 30days) according to Default time range (Varies per widget)?
Thank you very much in advance for your support
Vee
Vee
OP2 years agoOkay, I understood your comment for both 1) and 2). I am very new in programing too ^^, but try to do as more as I can. getting sharing token from API that you recommend last time is very good enough for my team. Thank you very much @Stuart Weenig for your advice and help :)
LM User
·2 years agoVee
OP2 years agoI would like to thanks @Stuart Weenig for helping me to create sharing token last time. Again, I am looking for 2 things about widget as follwoing;
1) Once sharing widget has been created with fix time_scale (like 7days, 30days), but Is it possible to get graph with the other time scale via browser like “starttime=123456&stoptime=56789&auth=LMSTv1%3xxxxx”
2) If we want to share whole dashboard. Is dashboard also able to create sharing_token like graph widget? I could not see via LM UI
Thank you very much
Vee
OP3 years agoWow! It works!! i really appreciate your help thank you very very very much Mr. @Stuart Weenig :)
LM User
·3 years agoIt 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.
Vee
OP3 years agoHi @Stuart Weenig
I have got “415Unsupported Media Type” as following detail
Vee
OP3 years agoWow, Let me try to do as your recommended.
i really appreciate your help thank you very much @Stuart Weenig :)
LM User
·3 years agoIt 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.