httparty


Can't convert String to integer or undefined method nil for []


Using Httparty, I get the following response
#parsed_reponse = > {"items" => {"#no" => "1", "#type" => "book", "#category" => "GENERAL" }}
when i use the following code to access #no, I am getting the
following error: "Can't convert String into Integer"
r = #response.parsed_response["items"]["#no"]
Can anyone help on this? I do get "Can't convert String into Integer"
or "Undefined method `[]' for nil:NilClass (NoMethodError)"
Can anyone explain this with an example?
I am no HTTParty expert but here is an example of what I do to iterate through all the data in a response:
class Items
include HTTParty
default_params :output => 'xml'
format :xml
base_uri '<base_uri>'
end
xml = Items.get('<xmlFile>')
xml["items"].each do |item|
puts Integer(item['#no'])
end

Related Links

HTTParty force_encoding: encode_with_ruby_encoding
Using plus signs in query strings with HTTParty
Can't convert String to integer or undefined method nil for []
HTTparty in Rhodes

Categories

HOME
turing-machines
cheerio
polymer
time-complexity
eslint
formal-languages
rsa
swt
spring-data-redis
tivoli
maxscript
crystal-lang
elasticsearch-5
ibeacon-android
jxl
jsonpath
tput
renjin
package-managers
linear-algebra
vuejs
pyramid
cfml
underscore.js
iis-express
browser-sync
uitapgesturerecognizer
dotspatial
recurring-events
testbed
glib
instantiation
sharding
ideascript
microsoft-metro
glm-math
print-css
logback-groovy
lpsolve
importerror
wcftestclient
activeperl
lightning
oozie-coordinator
rackspace-cloud
trigger.io
filenet
node-request
pure-css
redistributable
webjars
microstation
hclust
delta
mediametadataretriever
php-socket
cda
concurrentmodification
microsoft-reporting
flock
morton-number
sapscript
eoferror
fits
execve
deform
device-tree
paw
xml-namespaces
with-statement
ora-00904
codeplex
parallel-testing
functional-java
wxformbuilder
buffering
radiant
vbe
maven-scm
decoupling
amslidemenu
multiautocompletetextview
gtm-oauth2
rolify
kaleidoscope
octal
panda3d
jsr286
node-redis
catransform3d
xcelsius
svk
google-wave

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App