AWX cli project modify - Bad Request

Using AWX 23.1.0 trying to configure awx with the awxkit of the same version.
I try the following

awx -f human -v project modify --organization=mdc --credential=mdc --scm_type=git --scm_url=http://git.gsm.svc.cluster.local.:8080/mdc-nodeplays.git --scm_branch=23.10.11 --scm_update_on_launch=false mdc_23.10.11

and get
BadRequest credential must be scm

Trace output:

DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): awx-service.gsm.svc.cluster.local:80
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/ HTTP/1.1" 200 186
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/" elapsed: 0:00:00.071116
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.api.ApiV2'> by url: /api/v2/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/v2/ HTTP/1.1" 200 1931
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/v2/" elapsed: 0:00:00.069139
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Projects'> by url: /api/v2/projects/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "OPTIONS /api/v2/projects/ HTTP/1.1" 200 19395
DEBUG:awxkit.api.client:"OPTIONS http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/" elapsed: 0:00:00.120725
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Projects'> by url: /api/v2/projects/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "OPTIONS /api/v2/projects/1/ HTTP/1.1" 200 10419
DEBUG:awxkit.api.client:"OPTIONS http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/1/" elapsed: 0:00:00.136305
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "OPTIONS /api/v2/projects/1/update/ HTTP/1.1" 200 697
DEBUG:awxkit.api.client:"OPTIONS http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/1/update/" elapsed: 0:00:00.091384
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Projects'> by url: /api/v2/projects/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/v2/projects/?name=mdc_23.10.11 HTTP/1.1" 200 2805
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/?name=mdc_23.10.11" elapsed: 0:00:00.156888
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Project'> by url: /api/v2/projects/8/
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.organizations.Organizations'> by url: /api/v2/organizations/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/v2/organizations/?name=mdc HTTP/1.1" 200 3495
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/v2/organizations/?name=mdc" elapsed: 0:00:00.162672
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.organizations.Organization'> by url: /api/v2/organizations/2/
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.credentials.Credentials'> by url: /api/v2/credentials/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/v2/credentials/?name=mdc HTTP/1.1" 200 1632
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/v2/credentials/?name=mdc" elapsed: 0:00:00.141936
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.credentials.Credential'> by url: /api/v2/credentials/3/
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Projects'> by url: /api/v2/projects/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/v2/projects/?name=mdc_23.10.11 HTTP/1.1" 200 2805
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/?name=mdc_23.10.11" elapsed: 0:00:00.161478
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Project'> by url: /api/v2/projects/8/
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Project'> by url: /api/v2/projects/8/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "PATCH /api/v2/projects/8/ HTTP/1.1" 400 49
DEBUG:awxkit.api.client:"PATCH http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/8/" elapsed: 0:00:00.132049
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/awxkit/cli/__init__.py", line 25, in run
    cli.parse_resource()
  File "/usr/local/lib/python3.11/site-packages/awxkit/cli/client.py", line 166, in parse_resource
    response = self.parse_action(resource)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/cli/client.py", line 278, in parse_action
    return getattr(page, self.method)(**parsed)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/api/pages/page.py", line 464, in patch
    return self._create().patch(**payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/api/pages/page.py", line 277, in patch
    return self.page_identity(r, request_json=json)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/api/pages/page.py", line 234, in page_identity
    raise exc.BadRequest(exc_str, data)
awxkit.exceptions.BadRequest: Bad Request (400) received - {'credential': ["Credential kind must be 'scm'."]}
 <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>
BadRequest

The output doesn’t match the documentation

Looks like the create function also is getting the same error.

 awx -v -f human project create --name=mdc_23.10.11 --credential=mdc --organization=mdc --scm_type=git --scm_url=http://git.gsm.svc.cluster.local.:8080/mdc-nodeplays.git --scm_branch=23.10.11 --scm_update_onlaunch=false --wait
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): awx-service.gsm.svc.cluster.local:80
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/ HTTP/1.1" 200 186
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/" elapsed: 0:00:00.076966
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.api.ApiV2'> by url: /api/v2/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/v2/ HTTP/1.1" 200 1931
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/v2/" elapsed: 0:00:00.077850
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/ HTTP/1.1" 200 186
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/" elapsed: 0:00:00.078098
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "POST /api/login/ HTTP/1.1" 302 0
DEBUG:awxkit.api.client:"POST http://awx-service.gsm.svc.cluster.local:80/api/login/" elapsed: 0:00:00.592765
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/ HTTP/1.1" 200 186
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/" elapsed: 0:00:00.084446
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/ HTTP/1.1" 200 186
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/" elapsed: 0:00:00.083442
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Projects'> by url: /api/v2/projects/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "OPTIONS /api/v2/projects/ HTTP/1.1" 200 19395
DEBUG:awxkit.api.client:"OPTIONS http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/" elapsed: 0:00:00.109804
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Projects'> by url: /api/v2/projects/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "OPTIONS /api/v2/projects/1/ HTTP/1.1" 200 10419
DEBUG:awxkit.api.client:"OPTIONS http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/1/" elapsed: 0:00:00.128319
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "OPTIONS /api/v2/projects/1/update/ HTTP/1.1" 200 697
DEBUG:awxkit.api.client:"OPTIONS http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/1/update/" elapsed: 0:00:00.085747
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.credentials.Credentials'> by url: /api/v2/credentials/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/v2/credentials/?name=mdc HTTP/1.1" 200 1632
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/v2/credentials/?name=mdc" elapsed: 0:00:00.146375
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.credentials.Credential'> by url: /api/v2/credentials/3/
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.organizations.Organizations'> by url: /api/v2/organizations/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "GET /api/v2/organizations/?name=mdc HTTP/1.1" 200 3495
DEBUG:awxkit.api.client:"GET http://awx-service.gsm.svc.cluster.local:80/api/v2/organizations/?name=mdc" elapsed: 0:00:00.154721
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.organizations.Organization'> by url: /api/v2/organizations/2/
awx: unrecognized arguments: --scm_update_onlaunch=false
DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.projects.Projects'> by url: /api/v2/projects/
DEBUG:urllib3.connectionpool:http://awx-service.gsm.svc.cluster.local:80 "POST /api/v2/projects/ HTTP/1.1" 400 49
DEBUG:awxkit.api.client:"POST http://awx-service.gsm.svc.cluster.local:80/api/v2/projects/" elapsed: 0:00:00.119428
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/awxkit/cli/__init__.py", line 25, in run
    cli.parse_resource()
  File "/usr/local/lib/python3.11/site-packages/awxkit/cli/client.py", line 166, in parse_resource
    response = self.parse_action(resource)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/cli/client.py", line 276, in parse_action
    return page.post(parsed)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/cli/custom.py", line 162, in post
    response = self.page.post(kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/api/pages/page.py", line 458, in post
    return self._create().post(payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/api/pages/page.py", line 281, in post
    return self.page_identity(r, request_json=json)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/awxkit/api/pages/page.py", line 234, in page_identity
    raise exc.BadRequest(exc_str, data)
awxkit.exceptions.BadRequest: Bad Request (400) received - {'credential': ["Credential kind must be 'scm'."]}
 <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>
BadRequest

Not sure why in older versions of AWX, the job template had the credential option
Now that has been moved to the project.

After reading through the docs and the source some more, the credential for the project is related directly to being able to access the SCM.

So how do you define a credential for a job_template since that option is now gone?

Digging through the UI found the option to add credentials to a job template.
The API doesn’t provide that.
Turns out that it needs a second call to the API to associate a credential to the job template.

I guess some better examples or some usage are needed. Just the API descriptions seem to be less than sufficient.

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