# awx cli - Bad Request (400) received

**URL:** <https://forum.ansible.com/t/awx-cli-bad-request-400-received/37918>\
**Category:** AWX Project\
**Tags:** aws, awx\
**Created:** [April 23, 2023, 10:02am UTC](https://forum.ansible.com/t/awx-cli-bad-request-400-received/37918 "2023-04-23T10:02:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Den](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@Den](https://forum.ansible.com/u/Den)\
**Post date:** [April 23, 2023, 10:02am UTC](https://forum.ansible.com/t/awx-cli-bad-request-400-received/37918/1 "2023-04-23T10:02:01Z")

</div>

Hi,

I do export the “–job\_templates” resource with the following command:

(venv) root@awx-vm01:/srv# awx --conf.host [http://172.22.1.30:30080](http://172.22.1.30:30080) --conf.username admin --conf.password my\_password --conf.insecure export --job\_templates “Destroy aws-ec2-sg” \> job\_templates.json

It seems to be working well:

(venv) root@awx-vm01:/srv# cat job\_templates.json

{

“job\_templates”: [

{

“name”: “Destroy aws-ec2-sg”,

“description”: “”,

“job\_type”: “run”,

“playbook”: “playbooks/aws-ec2-sg-destroy.yml”,

“scm\_branch”: “”,

“forks”: 0,

“limit”: “”,

“verbosity”: 0,

“extra\_vars”: “—”,

“job\_tags”: “”,

“force\_handlers”: false,

“skip\_tags”: “”,

“start\_at\_task”: “”,

“timeout”: 0,

“use\_fact\_cache”: false,

“execution\_environment”: null,

“host\_config\_key”: “”,

“ask\_scm\_branch\_on\_launch”: false,

“ask\_diff\_mode\_on\_launch”: false,

“ask\_variables\_on\_launch”: false,

“ask\_limit\_on\_launch”: false,

“ask\_tags\_on\_launch”: false,

“ask\_skip\_tags\_on\_launch”: false,

“ask\_job\_type\_on\_launch”: false,

“ask\_verbosity\_on\_launch”: false,

“ask\_inventory\_on\_launch”: false,

“ask\_credential\_on\_launch”: false,

“ask\_execution\_environment\_on\_launch”: false,

“ask\_labels\_on\_launch”: false,

“ask\_forks\_on\_launch”: false,

“ask\_job\_slice\_count\_on\_launch”: false,

“ask\_timeout\_on\_launch”: false,

“ask\_instance\_groups\_on\_launch”: false,

“survey\_enabled”: true,

“become\_enabled”: false,

“diff\_mode”: false,

“allow\_simultaneous”: true,

“job\_slice\_count”: 1,

“webhook\_service”: “”,

“webhook\_credential”: null,

“prevent\_instance\_group\_fallback”: false,

“inventory”: {

“organization”: {

“name”: “GD Organization”,

“type”: “organization”

},

“name”: “GD Inventory - Static Hosts”,

“type”: “inventory”

},

“project”: {

“organization”: {

“name”: “GD Organization”,

“type”: “organization”

},

“name”: “GitLab Playbooks-Roles”,

“type”: “project”

},

“related”: {

“labels”: ,

“credentials”: ,

“schedules”: ,

“notification\_templates\_started”: ,

“notification\_templates\_success”: ,

“notification\_templates\_error”: ,

“survey\_spec”: {

“name”: “”,

“description”: “”,

“spec”: [

{

“question\_name”: “Security Group name”,

“question\_description”: “”,

“required”: true,

“type”: “text”,

“variable”: “ec2\_security\_group\_name\_tag”,

“min”: 3,

“max”: 30,

“default”: “aws-test999-sg”,

“choices”: “”,

“new\_question”: true

}

]

}

},

“natural\_key”: {

“organization”: {

“name”: “GD Organization”,

“type”: “organization”

},

“name”: “Destroy aws-ec2-sg”,

“type”: “job\_template”

}

}

]

}

And I’m trying to import the resource “–job\_templates” to another AWX host with the following command:

(venv) root@awx-vm01:/srv# awx --conf.host [http://172.22.1.33:30080](http://172.22.1.33:30080) --conf.username admin --conf.password my\_password --conf.insecure import \< job\_templates.json

I get an error message:

/api/v2/job\_templates/ “Destroy aws-ec2-sg”: Bad Request (400) received - {‘inventory’: [‘Must either set a default value or ask to prompt on launch.’]}.

Although the Inventory is listed in the “job\_templates.json” file for the selected Job Template.

My setup is:

[http://172.22.1.30:30080](http://172.22.1.30:30080)

AWX 22.1.0

AWX Operator 2.0.1

[http://172.22.1.33:30080](http://172.22.1.33:30080)

AWX 22.1.0

AWX Operator 2.0.1

(venv) root@awx-vm01:/srv# pip3 list

Package Version

* * *

awxkit 22.1.0

certifi 2022.12.7

charset-normalizer 3.1.0

idna 3.4

pip 20.0.2

pkg-resources 0.0.0

PyYAML 6.0

requests 2.28.2

setuptools 44.0.0

urllib3 1.26.15

(venv) root@awx-vm01:/srv# pip3 show awxkit

Name: awxkit

Version: 22.1.0

Summary: The official command line interface for Ansible AWX

Home-page: [https://github.com/ansible/awx](https://github.com/ansible/awx)

Author: Red Hat, Inc.

Author-email: [info@ansible.com](mailto:info@ansible.com)

License: Apache 2.0

Location: /srv/venv/lib/python3.8/site-packages

Requires: PyYAML, requests

Required-by:

Just need to figure out how to make it work all together (export/import).

Can anyone with awx cli working share how you put it all together?

Thanks.

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [April 26, 2023, 6:51pm UTC](https://forum.ansible.com/t/awx-cli-bad-request-400-received/37918/2 "2023-04-26T18:51:56Z")

</div>

do the inventories in the json structure exist in the database at the time of trying to run the import command? what if you create those manually first, then run the import, does it work?

AWX Team

---

<div class="post-metadata">

**Author:** ![Den](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@Den](https://forum.ansible.com/u/Den)\
**Post date:** [May 5, 2023, 4:19pm UTC](https://forum.ansible.com/t/awx-cli-bad-request-400-received/37918/3 "2023-05-05T16:19:37Z")

</div>

Hello AWX Team,

That’s exactly what I did.  
Created the inventory manually (via UI) and then run the import.  
But alas, it doesn’t work.

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [May 5, 2023, 5:27pm UTC](https://forum.ansible.com/t/awx-cli-bad-request-400-received/37918/4 "2023-05-05T17:27:45Z")

</div>

There could be a bug here, do you mind opening an AWX issue on github with this information? [https://github.com/ansible/awx/issues](https://github.com/ansible/awx/issues)

Can you also confirm that the names in the json export list perfectly match the names of the manually created resources in AWX (spaces, capitalizations, etc)

AWX Team
