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

  • SEARCH
  • Home
  • 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 6626353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:52:57+00:00 2026-05-25T21:52:57+00:00

I am trying to access a service which uses the url format. www.example.com/api/API_KEY/action The

  • 0

I am trying to access a service which uses the url format. http://www.example.com/api/API_KEY/action

The below code is a small example of what I’m trying to achieve.

require 'httparty'

class MyAPI
  include HTTParty
  debug_output $stdout

  base_uri "example.com/api/#{@api_key}"

  def initialize(api_key)
     @api_key = api_key
  end

  def statistics
    return self.class.get("/statistics")
  end
end

The server request:

MyAPI.new('apikey').statistics

comes out as

GET /api//statistics

I knew it was optimistic but I put the api_key variable in the base_uri. How do I make it so that the url uses the dynamic api_key?

  • 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-25T21:52:58+00:00Added an answer on May 25, 2026 at 9:52 pm

    You are missing a reader method for @api_key.

    Add the following to your class to allow the setting of @api_key after initialization.

    attr_accessor :api_key
    

    Or add to allow it to be read, but not set later.

    attr_reader :api_key
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to access an HTTPS based web service URL from a web/ear application
I have a windows service which is trying to access an xml file from
I am trying to access http://services-staging.cmtnyc.com/payment/payment.asmx web service and AuthorizeCreditTrip I checked this webservice
Im trying to access a web service from a remote computer. I managed to
I'm trying to access a SOAP service I don't control. One of the actions
I am trying to access the singleton instance created by my WCF service but
I'm trying to use HTTPWebRequest to access a REST service, and am having problems
I am trying to build a service mechanism which should be add-on based and
I am trying to write a web service in ASP.NET which enables an outside
I am trying to bind a service which is included in a Library project

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.