# JSON Request With Saved Object Find API

**URL:** https://discuss.elastic.co/t/json-request-with-saved-object-find-api/251265
**Category:** Kibana
**Created:** [October 7, 2020, 12:19pm UTC](https://discuss.elastic.co/t/json-request-with-saved-object-find-api/251265 "2020-10-07T12:19:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![git-blame](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/git-blame/32/76804_2.png) [@git-blame](https://discuss.elastic.co/u/git-blame)
#### Post date: [October 7, 2020, 12:19pm UTC](https://discuss.elastic.co/t/json-request-with-saved-object-find-api/251265/1 "2020-10-07T12:19:11Z")

</div>

In the Find API, there is a _has\_reference_ parameter which is an object with fields _type_ and _id_. However,

- There is no example I can find of how to format that as a URL (e.g., for a curl get)
- This [comment](https://discuss.elastic.co/t/kibana-api-for-automatic-export-all/201243/6) implies that I can send the request as JSON. But my attempts to do so does not work

```auto
curl -b cookie.txt -k -H 'Content-Type: application/json' -XGET 'https://localhost:5601/api/saved_objects/_find' -d '
{
    "type": "visualization",
    "hasReference": {
        "type": "index-pattern",
        "id": "728b8d30-5977-11ea-a830-91c011d847a4"
    }
}
> '
{"statusCode":400,"error":"Bad Request","message":"[request query.type]: expected at least one defined value but got [undefined]"}

```

- Note that if I include the type in the URL I will get data but it is obvious that the hasReference parameter as JSON request body was not processed.

Does anyone know how to either format a _has\_reference_ parameter or in general, send GET requests as JSON body to Kibana?

---

<div class="post-metadata">

### Author: ![cheiligers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheiligers/32/73114_2.png) [@cheiligers](https://discuss.elastic.co/u/cheiligers)
#### Post date: [October 7, 2020, 8:43pm UTC](https://discuss.elastic.co/t/json-request-with-saved-object-find-api/251265/2 "2020-10-07T20:43:56Z")

</div>

Hi @git-blame and welcome to the Discuss community!  
The [`saved_objects/_find` API](https://www.elastic.co/guide/en/kibana/master/saved-objects-api-find.html) doesn't support using `hasReference`. `hasReference` refers to saved objects that reference other saved objects like a dashboard referencing the visualization saved objects it contains.  
If there's a specific saved object you want to retrieve, you can try using the **experimental** [`get` API.](https://www.elastic.co/guide/en/kibana/master/saved-objects-api-get.html#saved-objects-api-get)

---

<div class="post-metadata">

### Author: ![git-blame](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/git-blame/32/76804_2.png) [@git-blame](https://discuss.elastic.co/u/git-blame)
#### Post date: [October 8, 2020, 12:44pm UTC](https://discuss.elastic.co/t/json-request-with-saved-object-find-api/251265/3 "2020-10-08T12:44:58Z")

</div>

So it turns out you can use the `has_reference` parameter if you URL encode the JSON object. For example:

```auto
curl -b cookie.txt -G 'https://localhost:5601/api/saved_objects/_find?type=visualization&fields=title' 
--data-urlencode 'has_reference={ "type": "index-pattern", "id": "728b8d30-5977-11ea-a830-91c011d847a4" }' 

```

You would only get visualization objects that references that object.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 5, 2020, 12:45pm UTC](https://discuss.elastic.co/t/json-request-with-saved-object-find-api/251265/4 "2020-11-05T12:45:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
