# Unsupported Media Type - issues when trying to do a comparison of spaces components and copying over into existing space all types in one ansible script

**URL:** <https://discuss.elastic.co/t/unsupported-media-type-issues-when-trying-to-do-a-comparison-of-spaces-components-and-copying-over-into-existing-space-all-types-in-one-ansible-script/356409>\
**Category:** Kibana\
**Created:** [March 28, 2024, 4:39pm UTC](https://discuss.elastic.co/t/unsupported-media-type-issues-when-trying-to-do-a-comparison-of-spaces-components-and-copying-over-into-existing-space-all-types-in-one-ansible-script/356409 "2024-03-28T16:39:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcarr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lcarr/32/104631_2.png) [@lcarr](https://discuss.elastic.co/u/lcarr)\
**Post date:** [March 28, 2024, 4:39pm UTC](https://discuss.elastic.co/t/unsupported-media-type-issues-when-trying-to-do-a-comparison-of-spaces-components-and-copying-over-into-existing-space-all-types-in-one-ansible-script/356409/1 "2024-03-28T16:39:39Z")

</div>

We are migrating from one space in our kibana to another - there are over 500 elements in the one space, visualizations, queries, lens, dashboards etc. We have been able to get a file created but when we run the ansible script - we are not able to do the comparison -

"msg": "Status code was 415 and not [200]: HTTP Error 415: Unsupported Media Type

This is our script : It is part of a larger solution with backup/copy/compare - this does not let us do the compare -

# Set Fact for Saved Object

- name: Set Fact for Saved Object  
set\_fact:  
saved\_object\_data: "{{ saved\_object.attributes | to\_nice\_json }}"

# Check if Saved Object Already Exists in Destination Space

- name: Check if Saved Object Already Exists in Destination Space  
set\_fact:  
exists\_in\_destination: false  
when: destination\_saved\_objects.saved\_objects | length \> 0

- name: Loop through destination saved objects  
loop: "{{ destination\_saved\_objects.saved\_objects }}"  
loop\_control:  
loop\_var: saved\_object\_item  
when: exists\_in\_destination is not defined  
set\_fact:  
exists\_in\_destination: "{{ saved\_object\_item.attributes.id == saved\_object.attributes.id }}"

- name: Debug exists\_in\_destination  
debug:  
var: exists\_in\_destination

# Pause execution here to inspect data from comparison

- name: Pause for inspection  
pause:  
prompt: "Inspect the data. Press Enter to continue."

# Post Saved Object(visualizations) to Destination Space(ds2) if Not Already Present

- name: Post Saved Object(visualizations) to Destination Space(ds2) if Not Already Present  
when: not exists\_in\_destination  
uri:  
url: "{{ destination\_space\_url }}/api/saved\_objects/\_import"  
method: POST  
body\_format: json # Use JSON format for the request body  
headers:  
Content-Type: "application/json" # Set the content type header to JSON  
kbn-xsrf: "true"  
Authorization: "ApiKey {{ dashboard\_api\_key }}"  
body: "{{ saved\_object\_data | to\_json }}"  
validate\_certs: false  
register: import\_response

# Assert that the response is JSON

- name: Assert that the response is JSON  
assert:  
that:  
- import\_response.json is defined  
msg: "The import response is not in JSON format"

Is there something that we are missing?

---

<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:** [April 25, 2024, 4:40pm UTC](https://discuss.elastic.co/t/unsupported-media-type-issues-when-trying-to-do-a-comparison-of-spaces-components-and-copying-over-into-existing-space-all-types-in-one-ansible-script/356409/2 "2024-04-25T16:40:26Z")

</div>

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