REST example from book not working


#1

Hello,

Running into an issue with the REST API example from the book “Mastering_CloudForms_Automation_Red_Hat”

/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- json/pure (LoadError) from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:inrequire’
from /opt/rh/rh-ruby23/root/usr/share/gems/gems/json-2.0.2/lib/json.rb:61:in rescue in <module:JSON>' from /opt/rh/rh-ruby23/root/usr/share/gems/gems/json-2.0.2/lib/json.rb:58:inmodule:JSON
from /opt/rh/rh-ruby23/root/usr/share/gems/gems/json-2.0.2/lib/json.rb:55:in <top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:135:inrequire’
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:135:in rescue in require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:144:inrequire’

Any ideas what is going on?
Thanks,
SN


#2

The test script was run from the appliance.


#3

Try copying the scripts directly from here: https://github.com/pemcg/mastering-automation-in-cloudforms-4.2-and-manageiq-euwe/tree/master/calling_automation_using_the_restful_api/scripts

I’ve used the run_via_api.rb script today on CFME 5.8.0 (MIQ Fine) and it worked ok

Which version of MIQ/CFME are you trying this on?

pemcg


#4

Hello Peter,

Copied script from github. No missing gem anymore. Ran into another issue

api.rb -d TestDomain -n “/Debug” -c “ObjectWalker” -i ObjectWalker -s localhost -u xxx -p xxx
Running automation method /Debug/ObjectWalker/ObjectWalker using parameters: {}
Checking completion state…
Checking completion state…
Checking completion state…
Checking completion state…
Checking completion state…
Checking completion state…
Checking completion state…
Checking completion state…
Request exited with status: Error
Returned message: Automation Request failed

CFME Version: 5.8.0.17

Thanks a bunch.
SN


#5

The namespace probably doesn’t need the leading ‘/’, but you should see more information about the failure in automation.log


#6

Peter,

Thank you. You’re right, no leading / for namespace and I had a typo in my domain name.

Thanks,
SN