Is there a Saved Objects API in Opensearch?

Elasticsearch has a Saved Objects API and it is in their documentation, but I can’t find it in the Opensearch documentation. I’ve tried the “curl -XPOST -k http:// localhost:5601/api/saved_objects/_export” kind of commands but it does not work. Has it been deprecated? If not, how do I access it?

@curlquest This worked for me with OpenSearch Dashboards 2.15.0

curl --insecure -X POST "https://localhost:5601/api/saved_objects/_export" -H "osd-xsrf: true" -H "Content-Type: application/json" -u admin:Eliatra123 -d'
{
  "type": ["index-pattern", "search", "visualization", "dashboard"]
}'

I’m getting “{“error”:“no handler found for uri [/api/saved_objects/_export] and method [POST]”}” as a response. I wonder if I don’t have something installed? It’s an Opensearch instance made from AWS.

@curlquest I’ve tested against standalone OpenSearch Dashboards deployment. If you have issues with managed AWS service then you should contact their support.

I executed following command but I was able to export only 4 objects. However there were 56 objects in total when I made the request via browser

curl --insecure -X POST "https://192.168.0.81:5601/api/saved_objects/_export" -H "osd-xsrf: true" -H "Content-Type: application/json" -u admin:opensearch -d'
{
  "type": "index-pattern"
}' 

How to resolve it to fetch all the saved objects. I have basically 56 index patterns saved and I want to export them

@Iqra_shafiq Do you mean 56 index pattern objects?

yes

I thinks it’s all about in which tenant you call this api, previously I followed another post in forum and come with this. sorry that I can’t mention them its been a while, it works with my v2.8 and maybe there is a better api for it in newer versions but check this out:

export user=
export pass=
export url_dashboard_socket=
export tenant=
export export_path=

mkdir -p $export_path
echo ""
echo "1 - save cookie"
echo ""

curl --header 'Content-Type: application/json' \
 --header 'osd-xsrf: true' \
 --cookie-jar ${export_path}/opensearch_dashboards-cookies.txt \
 --user "${user}:${pass}" --insecure  --location --request POST "${url_dashboard_socket}/auth/login" \
 --data-raw "
 {
    \"username\":\"${user}\",\"password\":\"${pass}\"
 }"

echo ""
echo "2 - view account based on saved cookie"
echo ""

curl --header 'Content-Type: application/json' \
 --header 'osd-xsrf: true' \
 --cookie ${export_path}/opensearch_dashboards-cookies.txt \
 --user "${user}:${pass}" --insecure  --location --request GET "${url_dashboard_socket}/api/v1/configuration/account" \
 | jq .

echo ""
echo "2 - change tenant"
echo ""

curl --header 'Content-Type: application/json' \
 --header 'osd-xsrf: true' \
 --cookie ${export_path}/opensearch_dashboards-cookies.txt \
 --cookie-jar ${export_path}/opensearch_dashboards-cookies.txt \
 --user "${user}:${pass}" --insecure  --location --request POST "${url_dashboard_socket}/api/v1/multitenancy/tenant" \
 --data-raw "
 {
    \"tenant\": \"${tenant}\", \"username\": \"${user}\"
 }"

echo ""
echo "echo 2 - view account based on saved cookie after changing tenant"
echo ""

curl --header 'Content-Type: application/json' \
 --header 'osd-xsrf: true' \
 --cookie ${export_path}/opensearch_dashboards-cookies.txt \
 --user "${user}:${pass}" --insecure  --location --request GET "${url_dashboard_socket}/api/v1/configuration/account" \
 | jq .

echo ""
echo "3- get all saved objects"
echo ""
curl --header 'Content-Type: application/json' \
 --header 'osd-xsrf: true' \
  --cookie ${export_path}/opensearch_dashboards-cookies.txt \
  -u ${user}:${pass} \
 --insecure --location --request POST "${url_dashboard_socket}/api/saved_objects/_export" \
 -d '{
    "type": ["index-pattern", "search", "visualization", "visualization-visbuilder", "dashboard", "url", "query", "config", "map"]
  }' | tee -a "${export_path}/all_saved_object.ndjson"