How to use api/shorten_url?

Examples in the documentation:

# 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:

 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

1 Like
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

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)))
1 Like

image
ok, I tried to click the button and I got it.

2 Likes

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