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

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?

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