location header from uri response

I’m using the uri module to call a REST API. The result of this is shown below. I now want to save the location portion into a variable to use later in my script.

How do I do that?

I’ve tried:

register: msg // register: content // register: status

I’m using the uri as a pre_task - if that makes any difference?

I’ve also trying using:

tasks:

  • debug: var=msg.location // - debug: var=content.location // - debug: var="{{ status.location}}" // -debug: var="{{ status.location | from_json }}"

Basically every combination of the obvious.