Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7677657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:28:20+00:00 2026-05-31T17:28:20+00:00

Hello Im using HTTParty to call for a remote json file that I need

  • 0

Hello Im using HTTParty to call for a remote json file that I need to extract the URL’s to use in one of my tests..
the json format goes something like:

  "manifest" : {
    "header" : {
      "generated" : "xxxxxxxxxxxxxxx",
      "name" : "xxxxxxxxxxx",
      "version" : "1.0.0"
    },
    "files" : [ {
      "file" : "blimp.zip",
      "url" : "http://www.xxx.xx/restaurants_blimp.zip",
      "checksum" : "ee98c9455b8d7ba6556f53256f95"
    }, {
      "file" : "yard.zip",
      "url" : "www.xxx.xx/yard.zip",
      "checksum" : "e66aa3d123f804f34afc622b5"
    }

on irb I can get all the sub hashes inside example: [‘manifest’][‘files’] and I can only get the url if I expecify which one.. like for example puts file[‘manifest’][‘files’][‘1’][‘url’] <– this does work on irb but since I need to get ALL url’s this is why I use .each but it gives me a cant convert to string error or similar

#!/usr/bin/env ruby

require 'httparty'

HOST=ARGV[0]
ID=ARGV[1]
VERSION=ARGV[2]


class MyApi
  include HTTParty
end

file = MyApi.get("http://#{HOST}/v1/dc/manifest/#{ID}/#{VERSION}")


file.each do |item|
 puts item['manifest']['files']['url']
end

not working but I can on IRB do a:

puts item[‘manifest’][‘files’][2][‘url’] <– and this will give me the url but with the .each will just complaint about cant convert to string or similar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:28:21+00:00Added an answer on May 31, 2026 at 5:28 pm

    Try the following:

    #!/usr/bin/env ruby
    
    require 'httparty'
    
    (HOST, ID, VERSION) = ARGV
    
    class MyApi
      include HTTParty
      format :json
    end
    
    response = MyApi.get("http://#{HOST}/v1/dc/manifest/#{ID}/#{VERSION}")
    
    puts response.inspect
    

    The addition of the format :json tells HTTParty to parse the response as JSON. Then you’ll get a hash you can iterate over properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i am using ORMLite 4.33. I have an entity class that gives me
I'm using HTTParty for my class, and I want to use the default_params method.
Hello iam using wordpress and i need to set permission for a plugin folder
hello Im using VB 2008 is it possible to set array items with one
Hello Im using OLE DB Source for get rows from a dBase IV file
Hello I am using jquery to do some ajax that calls in some data
I have to read a file called hello.txt using the following code on java/eclipse/android:
hello i am using joomla and i am trying to create an option that
Hello i'm using SQL server full-text search. when i use the FreeText predicate it
I have a class: class MyClass(object): @property def myproperty(self): return 'hello' Using mox and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.