Library Elements API GET by name returns array (#44743)

* Library Elements API GET by name returns array

Making a GET request to the Library Elements HTTP API `api/library-elements/name/:name` will return an **array** of Library Element objects, but the documentation says it will return a Library Element object.

Example cURL POST request:
`curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer XXXXXXXXXXX" -d @request.json "https://my.grafana.net/api/library-elements/"`

request.json
```json
{
  "model": {},
  "kind": 1,
  "name": "testing description3",
  "uid": "basic3",
  "id": 12345,
  "version": 2
}
```

Example cURL GET request:
`curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer XXXXXXXX" -d @request "https://my/api/library-elements/name/testing description3"`

Example response:
```json
{
    "result": [
        {
            . . .
        }
    ]
}
```

* Library Elements API fix bracket spacing
pull/44767/head
JM 3 years ago committed by GitHub
parent ac90c8d68d
commit 925333bfa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 60
      docs/sources/http_api/library_element.md

@ -176,35 +176,37 @@ HTTP/1.1 200
Content-Type: application/json Content-Type: application/json
{ {
"result": { "result": [
"id": 25, {
"orgId": 1, "id": 25,
"folderId": 0, "orgId": 1,
"uid": "V--OrYHnz", "folderId": 0,
"name": "API docs Example", "uid": "V--OrYHnz",
"kind": 1, "name": "API docs Example",
"type": "text", "kind": 1,
"description": "", "type": "text",
"model": {...}, "description": "",
"version": 1, "model": {...},
"meta": { "version": 1,
"folderName": "General", "meta": {
"folderUid": "", "folderName": "General",
"connectedDashboards": 1, "folderUid": "",
"created": "2021-09-27T09:56:17+02:00", "connectedDashboards": 1,
"updated": "2021-09-27T09:56:17+02:00", "created": "2021-09-27T09:56:17+02:00",
"createdBy": { "updated": "2021-09-27T09:56:17+02:00",
"id": 1, "createdBy": {
"name": "admin", "id": 1,
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56" "name": "admin",
}, "avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56"
"updatedBy": { },
"id": 1, "updatedBy": {
"name": "admin", "id": 1,
"avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56" "name": "admin",
} "avatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56"
} }
} }
}
]
} }
``` ```

Loading…
Cancel
Save