httparty


Using plus signs in query strings with HTTParty


I'm trying to get this url with HTTparty:
http://collections.museumvictoria.com.au/api/search?hasimages=yes&collectingarea=royal+exhibition+building&page=1
I'm using the query:
items = get("http://collections.museumvictoria.com.au/api/search", query: {has images: "yes", collecting area: "royal+exhibition+building", page: 1})
This returns 0 results however if I just copy and past the url into a browser it does return data. From my other tests it looks as though only collecting areas with plus signs in them fail to return results collectingarea: "arms" works).
Any idea how we should properly encode the plus signs to make this work in HTTParty?
Use HTTParty version >= v0.13.4 It's encode the query values internally.
However you can Override httparty's query strings normalizer.
Also you need to put underscore between words in query keys like has_images, collecting_area.
I tested this code and it works for me:
require 'httparty'
class Test
include HTTParty
def self.test
puts self.get("http://collections.museumvictoria.com.au/api/search", query: {has_images: "yes", collecting_area: "royal+exhibition+building", page: 1})
end
end
Test.test

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
embedded
assembly
google-cloud-platform
angular2-material
nsbundle
vxml
nuget-package
missing-data
nstableheaderview
special-characters
joomla3.0
p2p
arangodb
jquery-ui-sortable
renjin
azure-powershell
vuejs
jersey-1.0
breadth-first-search
undertow
href
ios10.2
beta
jboss6.x
licensing
corpus
paperjs
sqsh
kudu
sammy.js
openwhisk
sendbird
reverse
lubridate
searchkit
dm-script
flatmap
z-notation
apns-php
typesafe-config
unordered-map
doc
wmp
avcapturedevice
angular-http
uiimage
facebook-social-plugins
getchar
ntvs
opennms
term
automapper-5
convex-optimization
video-conferencing
skin
lsyncd
restore
juice-ui
testrail
cvxpy
delta
cifilter
gcloud-ruby
fuzzywuzzy
findfirst
kendo-upload
highland.js
linklabel
iokit
viola-jones
uncompress
nsurlsessiondatatask
snackbar
cakephp-2.7
formview
jama
unix-socket
angular-carousel
codeplex
memset
decoupling
clickbank
accesscontrolexception
isqlquery
printdialog
hidapi
cmmi
time.h
device-width
robotlegs
sentestingkit
veracity
listitem
cross-database
matlab-load
automationelement
http-daemon
inline-formset
codebase
nhprof
strtod
lalr
lobo-cobra
wordprocessingml
interop-domino
complex-event-processing
fdf
unmanagedresources
product-management
xslcompiledtransform

Resources

Encrypt Message