49957

Determining the parameters for “discovered_api”

This might be a really stupid question, but how do you determine the parameters to pass in the client "discovered_api" call? and then what is the executed "api_method"

For instance, I'm trying to call the Admin SDK Users List call which is "GET https://www.googleapis.com/admin/directory/v1/users".

There doesn't seem to be a clear way of extracting this from the API reference, or am I just looking in the wrong place?

Answer1:

I misunderstood the original question. I still think the other post is potentially valuable so I thought I'd add a new answer.

I experimented a bit and this will display the Title, id and whether or not it is preferred. The ID has a colon which seems to be where you separate the first and second argument when calling discovered_api.

puts "Title \t ID \t Preferred" client.discovered_apis.each do |gapi| puts "#{gapi.title} \t #{gapi.id} \t #{gapi.preferred}" end

Answer2:

I had this exact question. And for methods like get I figured it out.

Create your client and then do the following

api = client.discovered_api("admin", "directory_v1") puts "--- Users List ---" puts api.users.list.parameters puts "--- Users Get ---" puts api.users.get.parameters

This will print off the parameters. You can also use api.users.get.parameter_descriptions

Something that could be helpful if you are trying to probe into issues like this is to print off all the available methods. I typically do it like this.

puts api.users.insert.methods - Object.methods

If you try that one you will see that api.users.insert has the following methods after you take away the ones that are common to every object.

discovery_document api method_base method_base= description id http_method uri_template media_upload request_schema response_schema normalize_parameters generate_uri generate_request parameter_descriptions parameters required_parameters optional_parameters validate_parameters

I hope that helps.

James

Recommend

  • Error Handling in System.Net.HttpWebRequest::GetResponse()
  • Tkinter Grid Columnspan ignored
  • R add index column to data frame based on row values
  • How can I determine the author of a block of code programmatically in TFS?
  • Find all elements that have a certain data attribute (regardless of value)
  • iText as text Extracting/Reading from PDF on android
  • Packet modification with netfilter queue?
  • Uber API - requests endpoint cannot read read json
  • Unable to play media with vlc ocx
  • Embedded Google Maps in Rails not responsive
  • In matplotlib, how do you change the fontsize of a single figure?
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • Who propagate bugfixes across branches (corporate development)?
  • xcode don't localize specific strings
  • GAE: Way to get reference to an HttpSession from its ID?
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • What is the purpose of TaskExecutor in spring?
  • ViewController With Transparent Background Entering Current ViewController With Push Transition
  • Eclipse CDT error: Unable to compile
  • Excel's Macro-Recorder usage
  • Assign variable to the value in HTML
  • How to use carriage return with multiple line?
  • iOS: Detect app start via notification press
  • How to attach a node.js readable stream to a Sendgrid email?
  • Meteor: Do Something On Email Verification Confirmation
  • ilmerge with a PFX file
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Cassandra Data Model
  • Perl system calls when running as another user using sudo
  • Where to put my custom functions in Wordpress?
  • Hazelcast - OperationTimeoutException
  • Weird JavaScript statement, what does it mean?
  • RestKit - RKRequestDelegate does not exist
  • Revoking OAuth Access Token Results in 404 Not Found
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • WPF Applying a trigger on binding failure
  • need help with bizarre java.net.HttpURLConnection behavior
  • Running Map reduces the dimensions of the matrices
  • How to get NHibernate ISession to cache entity not retrieved by primary key