0

I try to run a command which takes some arguments and requires to pass some attributes to the API. I understand that call-process takes args as strings but any invocation complains about wrong-type-argument listp

(wrong-type-argument listp "'TEST=hpc_powerman'") 

(apply #'call-process "/usr/bin/openqa-cli" nil "mybuf" nil "api" "--osd" "-X" "post" "isos"
"'ISO=SLE-15-SP6-Online-aarch64-Build40.1-Media1.iso'"
"'DISTRI=sle'"
"'VERSION=15-SP6'"
"'FLAVOR=Online'"
"'ARCH=aarch64'"
"'_NOOBSOLETEBUILD=1'"
"'BUILD=40.1'"
"'_GROUP_ID=130'"
"'TEST=hpc_powerman'")

How it looks on terminal

400 Bad Request Error: missing parameters: DISTRI VERSION FLAVOR ARCH ❯ echo $? 1 ❯ openqa-cli api --pretty --host https://openqa.suse.de -X POST isos ISO=SLE-15-SP6-Online-aarch64-Build40.1-Media1.iso DISTRI=sle VERSION=15-SP6 FLAVOR=Online ARCH=aarch64 _NOOBSOLETEBUILD=1 BUILD=40.1 _GROUP_ID=130 TEST=hpc_powerman { "count" : 2, "failed" : [], "ids" : [ 12931264, 12931265 ], "scheduled_product_id" : 2004035 } 

I tried to escape the = but it doesnt make any difference. Another attempt was to send the last part as one string.

Any ideas how can i make this work?

1 Answer 1

3

The last argument to apply must be a list, see the documentation (emphasis mine)

Call FUNCTION with our remaining args, using our last arg as list of args.

You can group all arguments passed to the command in a quoted list, this has the (IMHO) nice side effect to show they are all related and distinct from the other arguments of call-process

(apply #'call-process "/usr/bin/openqa-cli" nil "mybuf" nil '("api" "--osd" "-X" "post" "isos" "'ISO=SLE-15-SP6-Online-aarch64-Build40.1-Media1.iso'" "'DISTRI=sle'" "'VERSION=15-SP6'" "'FLAVOR=Online'" "'ARCH=aarch64'" "'_NOOBSOLETEBUILD=1'" "'BUILD=40.1'" "'_GROUP_ID=130'" "'TEST=hpc_powerman'")) 

There is an even simpler solution, unless your real code is more complex and really need apply you can get rid of it and use call-process directly

(call-process "/usr/bin/openqa-cli" nil "mybuf" nil "api" "--osd" "-X" "post" "isos" "'ISO=SLE-15-SP6-Online-aarch64-Build40.1-Media1.iso'" "'DISTRI=sle'" "'VERSION=15-SP6'" "'FLAVOR=Online'" "'ARCH=aarch64'" "'_NOOBSOLETEBUILD=1'" "'BUILD=40.1'" "'_GROUP_ID=130'" "'TEST=hpc_powerman'") 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.