# How to use api/shorten\_url?

**URL:** <https://discuss.elastic.co/t/how-to-use-api-shorten-url/283423>\
**Category:** Kibana\
**Created:** [September 6, 2021, 9:02am UTC](https://discuss.elastic.co/t/how-to-use-api-shorten-url/283423 "2021-09-06T09:02:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [September 6, 2021, 9:02am UTC](https://discuss.elastic.co/t/how-to-use-api-shorten-url/283423/1 "2021-09-06T09:02:18Z")

</div>

Examples in the documentation:

```auto
# curl -H "kbn-xsrf: reporting" -XPOST http://192.168.10.148:5601/api/shorten_url -d '
> {
> "url": "/app/kibana#/dashboard?_g=()&_a=(description:'',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),panels:!((embeddableConfig:(),gridData:(h:15,i:'1',w:24,x:0,y:0),id:'8f4d0c00-4c86-11e8-b3d7-01146121b73d',panelIndex:'1',type:visualization,version:'7.0.0-alpha1')),query:(language:lucene,query:''),timeRestore:!f,title:'New%20Dashboard',viewMode:edit)"
> }'

```

My example:

```auto
 curl -H "kbn-xsrf: reporting" -XPOST http://192.168.10.148:5601/api/shorten_url -d '
{
  "url": "s/apm/app/discover#/view/816a0d70-0eea-11ec-9353-5d4977dfe7ef?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(columns:!(trace.id,service.name,http.request.method,url.path,http.request.body.original,http.response.status_code),filters:!(('$state':(store:appState),meta:(alias:'only%20show%20transaction',disabled:!f,index:b96eca80-ad0c-11ea-b618-530f4c7c7106,key:_index,negate:!f,params:(query:'apm-*-transaction-*'),type:phrase),query:(match_phrase:(_index:'apm-*-transaction-*'))),('$state':(store:appState),meta:(alias:!n,disabled:!f,index:b96eca80-ad0c-11ea-b618-530f4c7c7106,key:agent.name,negate:!f,params:(query:dotnet),type:phrase),query:(match_phrase:(agent.name:dotnet)))),index:b96eca80-ad0c-11ea-b618-530f4c7c7106,interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))"
}'

```

`{"statusCode":400,"error":"Bad Request","message":"[request body.url]: expected value of type [string] but got [undefined]"}`

The results are all type errors

---

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [September 7, 2021, 5:01am UTC](https://discuss.elastic.co/t/how-to-use-api-shorten-url/283423/2 "2021-09-07T05:01:42Z")

</div>

```auto
curl -H 'Content-Type: application/json' -H 'kbn-xsrf: true' -XPOST http://192.168.10.148:5601/api/shorten_url -d '
{
  "url": "/app/discover#/view/816a0d70-0eea-11ec-9353-5d4977dfe7ef?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(columns:!(trace.id,service.name,http.request.method,url.path,http.request.body.original,http.response.status_code),filters:!(('$state':(store:appState),meta:(alias:'only%20show%20transaction',disabled:!f,index:b96eca80-ad0c-11ea-b618-530f4c7c7106,key:_index,negate:!f,params:(query:'apm-*-transaction-*'),type:phrase),query:(match_phrase:(_index:'apm-*-transaction-*'))),('$state':(store:appState),meta:(alias:!n,disabled:!f,index:b96eca80-ad0c-11ea-b618-530f4c7c7106,key:agent.name,negate:!f,params:(query:dotnet),type:phrase),query:(match_phrase:(agent.name:dotnet)))),index:b96eca80-ad0c-11ea-b618-530f4c7c7106,interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))"
}'

```

I think I solved this problem, but a new problem arises.

How to generate URLs for non-default spaces?

For example, this url

```auto
http://192.168.10.148:5601/s/apm/app/discover#/view/816a0d70-0eea-11ec-9353-5d4977dfe7ef?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(columns:!(trace.id,service.name,http.request.method,url.path,http.request.body.original,http.response.status_code),filters:!(('$state':(store:appState),meta:(alias:'only%20show%20transaction',disabled:!f,index:b96eca80-ad0c-11ea-b618-530f4c7c7106,key:_index,negate:!f,params:(query:'apm-*-transaction-*'),type:phrase),query:(match_phrase:(_index:'apm-*-transaction-*'))),('$state':(store:appState),meta:(alias:!n,disabled:!f,index:b96eca80-ad0c-11ea-b618-530f4c7c7106,key:agent.name,negate:!f,params:(query:dotnet),type:phrase),query:(match_phrase:(agent.name:dotnet)))),index:b96eca80-ad0c-11ea-b618-530f4c7c7106,interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))

```

---

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [September 7, 2021, 5:06am UTC](https://discuss.elastic.co/t/how-to-use-api-shorten-url/283423/3 "2021-09-07T05:06:21Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/8/8/883bc2e87fc1a69d2c155a39916d2a3351b9dce5.png)  
ok, I tried to click the button and I got it.

---

<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:** [October 5, 2021, 5:07am UTC](https://discuss.elastic.co/t/how-to-use-api-shorten-url/283423/4 "2021-10-05T05:07:17Z")

</div>

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