DerRabe DerRabe - 6 months ago 3
Ruby Question

HTTParty headers not working in ruby script

I am trying to get the following curl command (which works) replicated in some Ruby code, however the 'Customer-Id' header part seems to not get sent/picked up by the API.

The curl command is:

curl -u ‘’ -H ‘Customer-Id: 243’

which returns info on that customer. However in Ruby, the following is not working:

auth = {
username: “”,
password: "#{pass}"

@result = HTTParty.get("",:basic_auth => auth, :headers => { ‘Customer-Id: 243’ } ).parsed_response
puts @result

If anyone has any ideas what I am doing wrong here, it would be appreciated!


Looking at your code, there is an error:

:headers => { ‘Customer-Id: 243’ }

Try this way:

:headers => {'Customer-Id' => 243}