How do I update Grafana dashboard through it's API - grafana

I want to update the grafana dashboard through its API but i have found out 2 problems:
i got an 412 HTTP error {'message': 'A dashboard with the same name in the folder already exists', 'status': 'name-exists'}
when i change the name of the dash board it is getting moved to general folder
i got the json for updating the dashboard by:
getting current state of dashboard by downloading it through API
changing a few variables (right now i just changed those trying to make it stay in current folder)
response_json["meta"]["folderId"] = folder_id
response_json["meta"]["folderUid"] = folder_uid
response_json["meta"]["overwrite"] = True
response_json["dashboard"]["uid"] = dashboard_uid
response_json["dashboard"]["id"] = dashboard_id
I'm not changing anything else, i don't know therefore why I'm getting problems with name-exists; ofc it exists i want to update it not create a new one, so its expected that the dashboard exists.
I have tried changing the name of the dashboard.

Related

Issue under github widget- No repos found with matching url and branch

I am setting everything according to the docs. Why is the app returning the error at the bottom of the dialog below 'Save'? The repo exists!
EDIT
The api server log reports that it's trying to run a query on the options.url on the collector items collection, but the collection item doesn't have this field set up:
2022-11-14 05:11:31,089 [http-nio-8080-exec-6] DEBUG o.s.data.mongodb.core.MongoDbUtils - Getting Mongo Database name=[dashboarddb]
2022-11-14 05:11:31,107 [http-nio-8080-exec-6] INFO c.c.d.a.t.JwtAuthenticationFilter - correlation_id=NULL application=hygieia, service=api, requester=admin, duration=135, uri=/api/collector/item/type/searchField/scm, request_method=GET, status=200, client_ip=127.0.0.1, x-forwarded-for=null, request_params=search:[https://github.com/githubtraining/hellogitworld.git],searchField:[options.url],size:[20]
I spent a lot of time investigating. I was able to work around the issue by adding manually the repo url and branch to the collector_items entry for GitHub/SCM in the dashboarddb mongodb. The submit() function in the UI is not working correctly. The field is not in url.options.url because url contains the string. Finally, the dashboardId is set wrongly on the collector_items. It pointed to Product while it should have pointed to SCM collector.

Azure DevOps: Rule with Area ID not working

I have created a rule that makes a field mandatory if the area ID is 12. However, the rule doesn't work. Nothing happens. If I change the condition to another case (e.g. status of a work item), it works.
My Rule:
What am I doing wrong? Can anyone help?
API Request:
From above API request, i can see you were trying to create the rule for the root area path.
I tested and found the rule doesnot work if the the Area ID is set to id of the Root Area Path.
If you intend to set the rule for the root area path of your project. You can change the
rule Conditions to Team Project = Team Project Name as workaround. See below:
If you have child area paths under the root area path and intend to create rules for the children area path. You need to get the area id of the child area path. And set the rule Conditions to Area ID = ID of ChildrenAeaPath.(Rule for children area path works perfectly).
See below Api request to get the children area path id.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/classificationnodes/{structureGroup}?$depth={$depth}&api-version=5.1
Are you by any chance trying to modify an existing rule - have you tried creating a brand new rule? I had this issue when I was trying to modify an existing rule that was disabled earlier. Even though the rule was enabled back, nothing would happen when the work item was modified.
After I created a new rule with the same condition as yours, it worked for me.

Defining a new variable in order to make a huge iteration giving me an error

I have an endpoint, you can have información about products
{{URL_API}}/products/
If i perform a GET method over that endpoint i will obtain the information of every product
BUT i can also specify the product that i want to know about, i.e:
{{URL_API}}/products/9345TERFER (the last code is the id of the product, called SKU)
The problem is that if i want to make a CSV in order to update the information of different products i have to define a variable called sku in the endpoint so i will be able to pass the corresponding SKU
I want to create the variable {{sku}} but i do not understand how to do that.. i tried so many times and i failed, i've searched a lot but i do not really understand
Also, should i use ":" before the declaration of the variable? i mean:
{{URL_API}}/products/:{{sku}}
or simply:
{{URL_API}}/ns/products/{{sku}}
Can you help me?
I'm super lost :(
EDIT:
I want to perform a PUT method, i want to pass different values to the body and then.. send the request (it throws an error: 404 not found)
This is what i did:
PUT|{{URL_API}}/products/{{sku}}
body:
{
"tax_percentage":"{{tax_percentage}}",
"store_code":"{{store_code}}",
"markup_top":"{{markup_top}}",
"status":"{{status}}",
"group_prices": [
{
"group":"{{class_a}}",
"price":"{{price_a}}",
"website":"{{website_a}}"
}
]
}
CSV:
POSTMAN:
Your issue seems to be just a basic understanding of how data files work with variables in Postman, here's a simple example that will work the same way for you too.
This is a basic request I'm using to resolve the variable from the data file - It's a GET request but that doesn't matter as all we're look at here is using a data file to resolve variables. All you need to do is ensure the URL is correct and that you SAVE the request before using the runner.
Here's a simple CSV file created in a text editor. The heading sku in the name on the variable it will reference inside the Postman request. Each value under that is the value that will be used for each iteration.
In the Runner, select your Collection from the list (If you have more than one) then select the CSV file. Once imported, you will be able to see a preview of the data.
If that's correct, press the Run button. The Runner will then iterate through the file and pick up the sku value in the CSV file and use it in the request. I've expanded one of the requests so you can see that the value was used in the request.

Is it possible to change widget data of dashboards through the Smartsheet API?

I'm trying to automate regular creation of dashboards and seeing if it's possible to change the data in widgets programmatically through the API. Is it possible for this to be done?
I've tried programming with the API in both C# and Python, but always get stuck at finding a way to edit the contents of a widget.
Example of what I've tried in C#
Sight newSight = new Sight();
newSight.Name = "New Sight Name";
newSight.Id = 1111222223333;
Widget widg = new Widget();
widg.Type = Smartsheet.Api.Models.WidgetType.TITLE;
widg.Contents.HtmlContent = "<p>New Title</p>";
newSight.Widgets[0] = widg;
smartsheet.SightResources.UpdateSight(newSight);
Error message for this one I get is:
"System.NullReferenceException: 'Object reference not set to an instance of an object.'
Smartsheet.Api.Models.Widget.Contents.get returned null."
For the HtmlContent line.
Another error message I've gotten is saying:
"Smartsheet.Api.InvalidRequestException: 'Unable to parse request. The following error occurred: Field "contents" was of unexpected type.'"
Which is when get a Sight and then try to change the contents in one of its widgets.
I'm also open to ideas on automating dashboard creations if possible.
Thank you.
At this moment, it's only possible to update the name of a dashboard via the API. Additional functionality is on the roadmap, but for now, you'll need to either edit the widgets in the UI, or edit the source data, i.e., in the reports or sheets that populate the dashboard.

TYPO3 WEC_Map Extension <script> Tag not inserted in HTML

I’m using Typo3 (Version 6.2.14) and upgraded WEC_Map to version 3.1.3 because I saw a warning on my map which says that I need to use an API key for Google Maps.
So I’ve generated an API key for "Maps Static API" and inserted it in WEC Map Admin. (I’ve used the same key for Browser API Key and Server API Key. Only difference is that I’ve added the secret for the Browser API Key separated by a comma.)
If I’ve visit my FE User Map in the backend the map is showing.
In the frontend instead I get the following error: "
There doesn't seem to be anything to display. Make sure the map is configured correctly and there are users or markers set".
Inspecting the source code I saw that the script tag to maps.googleapis.com is not generated. It looks like this is causing the issue, but I don't know why it is happening.
I hope that someone using a similar setup can point me into the right direction.
Thank you guys. (It would be nice if someone could add the Tag for WEC_Map)
Ok I resolved this. The problem was that I was using the userGroups setting to filter the map markers by multiple user groups.
plugin.tx_wecmap_pi2 {
height = 500
width = 500
showDirections = 1
prefillAddress = 0
initialMapType = G_HYBRID_MAP
controls.mapControlSize = large
controls.showOverviewMap = 1
controls.showMapType = 1
controls.showScale = 1
userGroups = 2,3,5
pid = 2,3,5 # <-- This uses a AND condition
}
Since this setting is using an AND condition under the hood I received the error "There doesn't seem to be anything to display. Make sure the map is configured correctly and there are users or markers set"
In fact I opened a feature request for this 3 years ago. Unfortunately the feature request never made it into the plugin. But Jan Bartels posted a workaround as reply to the feature request. This workaround got lost while updating the extension.
Also recomment to the extension authors to make it more clear in their documentation that the property userGroups uses a AND condition.