No implicit conversion of String into Integer (TypeError)?

user3137647

I'm trying to write a script that will get a system ID from Red Hat Satellite/Spacewalk, which uses XMLRPC. I'm trying to get the ID which is the first value when using the XMLRPC client using the system name.

I'm referencing the documentation from Red Hat for the method used below:

#!/usr/bin/env ruby
require "xmlrpc/client"


@SATELLITE_URL = "satellite.rdu.salab.redhat.com"
@SATELLITE_API = "/rpc/api"
@SATELLITE_LOGIN = "********"
@SATELLITE_PASSWORD = "*******"

@client = XMLRPC::Client.new(@SATELLITE_URL, @SATELLITE_API)

@key = @client.call("auth.login", @SATELLITE_LOGIN, @SATELLITE_PASSWORD)

@getsystemid = @client.call("system.getId", @key, 'cfme038')

print "#{@getsystemid}"

@systemid = @getsystemid ['id']

The output of getsystemid looks like this:

[{"id"=>1000010466, "name"=>"cfme038", "last_checkin"=>#<XMLRPC::DateTime:0x007f9581042428 @year=2013, @month=12, @day=26, @hour=14, @min=31, @sec=28>}]

But when I try to just get just id I get this error:

no implicit conversion of String into Integer (TypeError)

Any help is appreciated

Arup Rakshit

Write as

@systemid = @getsystemid[0]['id']

Your @getsystemid is not a Hash, it is an Array of Hash. @getsystemid[0] will give you the intended hash {"id"=>1000010466, "name"=>"cfme038", "last_checkin"=>#}. Now you can use Hash#[] method to access the value of the hash by using its keys.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

no implicit conversion of String into Integer (TypeError)

From Dev

ruby - json no implicit conversion of String into Integer (TypeError)

From Dev

Chef: no implicit conversion of String into Integer TypeError

From Dev

ruby - json no implicit conversion of String into Integer (TypeError)

From Dev

TypeError: no implicit conversion of String into Integer on association

From Dev

implicit conversion string to integer

From Dev

TypeError: no implicit conversion of Symbol into Integer

From Dev

No implicit conversion of Array into Integer (TypeError)

From Dev

TypeError - no implicit conversion of Symbol into Integer

From Dev

Why do I get "no implicit conversion of String into Integer (TypeError)"?

From Dev

no implicit conversion of Hash into String (TypeError)

From Dev

no implicit conversion of Hash into String (TypeError)

From Dev

TypeError: no implicit conversion of nil into String

From Dev

Geting a Typeerror with hashes (No implicit conversion of symbol into integer)

From Dev

TypeError: no implicit conversion of Symbol into Integer - Ruby on Rails

From Dev

Geting a Typeerror with hashes (No implicit conversion of symbol into integer)

From Dev

TypeError: no implicit conversion of Symbol into Integer Array of Hashes

From Dev

Nested Attributes Error: no implicit conversion of String into Integer

From Dev

Chef attributes "no implicit conversion of String into Integer"

From Dev

RSpec - Type error - no implicit conversion of String into Integer

From Dev

No implicit conversion of string into integer on ruby on rails

From Dev

Chef attributes "no implicit conversion of String into Integer"

From Dev

ActionView::Template::Error (no implicit conversion of String into Integer)

From Dev

Nested Attributes Error: no implicit conversion of String into Integer

From Dev

JSON no implicit conversion of String into Integer in Ruby

From Dev

no implicit conversion of String into Integer Ruby on Rails

From Dev

Ruby - TypeError: no implicit conversion of Hash into String

From Dev

Ruby no implicit conversion of Fixnum into String (TypeError)

From Dev

TypeError: no implicit conversion of nil into String error

Related Related

  1. 1

    no implicit conversion of String into Integer (TypeError)

  2. 2

    ruby - json no implicit conversion of String into Integer (TypeError)

  3. 3

    Chef: no implicit conversion of String into Integer TypeError

  4. 4

    ruby - json no implicit conversion of String into Integer (TypeError)

  5. 5

    TypeError: no implicit conversion of String into Integer on association

  6. 6

    implicit conversion string to integer

  7. 7

    TypeError: no implicit conversion of Symbol into Integer

  8. 8

    No implicit conversion of Array into Integer (TypeError)

  9. 9

    TypeError - no implicit conversion of Symbol into Integer

  10. 10

    Why do I get "no implicit conversion of String into Integer (TypeError)"?

  11. 11

    no implicit conversion of Hash into String (TypeError)

  12. 12

    no implicit conversion of Hash into String (TypeError)

  13. 13

    TypeError: no implicit conversion of nil into String

  14. 14

    Geting a Typeerror with hashes (No implicit conversion of symbol into integer)

  15. 15

    TypeError: no implicit conversion of Symbol into Integer - Ruby on Rails

  16. 16

    Geting a Typeerror with hashes (No implicit conversion of symbol into integer)

  17. 17

    TypeError: no implicit conversion of Symbol into Integer Array of Hashes

  18. 18

    Nested Attributes Error: no implicit conversion of String into Integer

  19. 19

    Chef attributes "no implicit conversion of String into Integer"

  20. 20

    RSpec - Type error - no implicit conversion of String into Integer

  21. 21

    No implicit conversion of string into integer on ruby on rails

  22. 22

    Chef attributes "no implicit conversion of String into Integer"

  23. 23

    ActionView::Template::Error (no implicit conversion of String into Integer)

  24. 24

    Nested Attributes Error: no implicit conversion of String into Integer

  25. 25

    JSON no implicit conversion of String into Integer in Ruby

  26. 26

    no implicit conversion of String into Integer Ruby on Rails

  27. 27

    Ruby - TypeError: no implicit conversion of Hash into String

  28. 28

    Ruby no implicit conversion of Fixnum into String (TypeError)

  29. 29

    TypeError: no implicit conversion of nil into String error

HotTag

Archive