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
fabricjs
search
ecmascript-6
pagination
alexa-skills-kit
jax-rs
3d
youtube-data-api-v3
saml-2.0
shiro
error-handling
can
yandex
settings
tvos
code-coverage
google-admin-sdk
title
special-characters
syntaxnet
categorical-data
openpyxl
android-securityexception
redis-sentinel
ipmitool
stellar.js
package.json
null-pointer
standards
video-editing
sigma.js
gmm
string-concatenation
roslyn
dynamically-generated
beta
strongname
jboss6.x
delimiter
entity-relationship-model
recurring-events
quickfixj
rselenium
apiary.io
latitude-longitude
metaprogramming
spring-mvc-test
setup.py
tasm
resolution
stringtokenizer
skylink
berkeley-db-je
jboss-4.2.x
spring-integration-sftp
launchctl
rserve
insight
remedy
pair-programming
filenet
stax
winusb
google-cloud-console
spring-cloud-feign
np-spring
themoviedb-api
extjs-grid
text-search
sha512
ms-access-2000
osc
mass-assignment
structuremap3
machine-instruction
ray
menubar
amslidemenu
observium
onload-event
cascadingdropdown
wimax
android-loadermanager
fragmenttransaction
ikimagebrowserview
role
entitydatasource
mbeans
unattended-processing
svk
instantiationexception
silent
binomial-heap
build-environment
dsl-tools
mathematical-notation
entitykey
httpcookie
contentpresenter
leader
blind

Resources

Encrypt Message