Dashboards & Visualizations

REST API for Splunk Dashboard update giving error for complex XML

shirlal
Engager

I have a complex Splunk Dashboard that needs to be updated through REST API.
The Dashboard was created manually, so the Dashboard XML is very large with many graphs,charts and complex search queries.

I am able to do a GET of the dashboard contents.

But when I try to update dashboard via POST and pass entire XML as eai:data, I get  the error:
Unparsable URI-encoded request data .

shirlal_0-1624869620763.png

 

When I try to pass the xml as file (request.xml) for Curl  :
curl -ku username:pwd -X POST -H "Content-Type:text/xml"  -d 'name=testdashboard' -d 'eai:data=@request.xml' https://my_splunk_url:8089/servicesNS/username/appspace/data/ui/views

<?xml version="1.0" encoding="UTF-8"?>
<response>
<messages>
<msg type="ERROR">Error parsing XML on line 1: Start tag expected, '&lt;' not found
</msg>
</messages>
</response>

In the request.xml have tried to replace <form> with &lt;form&gt;  still no luck.

Can someone please advise how to update large complex XML through REST API?

Labels (4)
Tags (2)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@shirlal 

After many experiments in this week I think this shell script will help you.

#!/bin/sh
data=`cat request.xml`
param=`echo "eai:data=$data"`

res=`curl -ku admin:admin123 https://localhost:8089/servicesNS/admin/search/data/ui/views/ -d 'name=testdashboard' --data-urlencode "$param"`
echo $res

 

Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

View solution in original post

kamlesh_vaghela
SplunkTrust
SplunkTrust

@shirlal 

After many experiments in this week I think this shell script will help you.

#!/bin/sh
data=`cat request.xml`
param=`echo "eai:data=$data"`

res=`curl -ku admin:admin123 https://localhost:8089/servicesNS/admin/search/data/ui/views/ -d 'name=testdashboard' --data-urlencode "$param"`
echo $res

 

Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

shirlal
Engager

@kamlesh_vaghela 

Thank you this solution worked perfectly !

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...