我通过Ruby使用Rally API( http://developer.help.rallydev.com/ruby-toolkit-rally-rest-api-json )。 我想查询Portfolio项目的属性(字段?)。 我有工作代码,例如这可以正常工作(虽然它似乎显示名称,而不是ID – 我期待的东西像’T30’,但这显示’这是我的倡议的名称’): pi_query.order = “FormattedID Asc” 通过反复试验,我也看到了 pi_query.order = “Name Asc” 也有效。 我的问题:我可以在这里使用什么价值观? 我找了几个小时。 名称,FormattedID和描述工作; 家长没有。 我找不到参考文档。 (我正在尝试编写一个自定义报告,显示项目组合项目是一种更易读的方式 – 以我可以打印的某种嵌套方式显示的主题,主动性和function.Rally中的Portfolio Hierarchy应用程序不会提供一个可打印的视图,所以我希望为它编写一个快速脚本。我不需要太多,主要是名称,以及这个东西是主题,主动性还是function。这样的东西:) T30 My first theme I65 The first initiative F44 The first feature under that F45 Another feature I66 Another initiative T31 My second theme I67 Yet another initiative
我目前正在使用RoR制作API,我需要创建一个具有虚拟属性和关联对象的对象。 问题是当我返回具有虚拟属性的对象时,序列化程序不会启动。 这是foo_controller返回的对象 { :id=>280, :virtual=>”y8st07ef7u” :user_id=>280 } :virtual是虚拟属性,user_id是关联表的ID – User。 我的目标是做到这一点 { :id=>280, :virtual=>”y8st07ef7u”, :user=>{ :id=>280, :name=>’foo’ } } Foo_controller设置 class Api::V1::FoosController :virtual), status: 200 end Foo_model设置 class Foo < ActiveRecord::Base belongs_to :user attr_accessor:virtual def set_attribute(path) self.virtual = path end end Foo_serializer设置 class FooSerializer < ActiveModel::Serializer attributes :id, :virtual has_one :user end Foo迁移设置 class […]
我刚刚发布了一个ruby gem来使用一些基于HTTP API的JSON: https://github.com/solyaris/blomming_api 我的naif ruby代码只是将API端点(json_data)返回的复杂/嵌套JSON数据结构转换为ruby Hashes(hash_data),以一对一的扁平转换(JSON到ruby散列,反之亦然)。 达的很好,但…… 我想编程接口更“高级”。 也许为每个端点设置类资源,但我对智能实现感到困惑。 让我用抽象代码解释一下。 假设我有一个API接收的复杂/嵌套JSON,通常是一个哈希数组,递归嵌套如下(想象示例): json_data = ‘[{ “commute”: { “minutes”: 0, “startTime”: “Wed May 06 22:14:12 EDT 2014”, “locations”: [ { “latitude”: “40.4220061”, “longitude”: “40.4220061” }, { “latitude”: “40.4989909”, “longitude”: “40.48989805” }, { “latitude”: “40.4111169”, “longitude”: “40.42222869” } ] } }, { “commute”: { “minutes”: 2, “startTime”: […]
我正在使用Oauth gem在APi中开发Linked。 同样的gem对我的Twitter API工作得很好,但在Linkedin API的情况下,我收到请求令牌,当它试图获取访问令牌时,它返回错误 OAuth ::问题exception:parameter_absent 代码如下.. consumerKey = “*************************” consumerSecret = “*************************” callbackUrl = “http://localhost/” apiURL = “https://api.linkedin.com” request_token_path = “/uas/oauth/requestToken” access_token_path = “/uas/oauth/accessToken” authorize_path = “/uas/oauth/authorize” @consumer = OAuth::Consumer.new(consumerKey,consumerSecret, { :site => apiURL, :scheme => :header, :http_method => :post, :request_token_path => request_token_path, :access_token_path => access_token_path, :authorize_path => authorize_path }) unless(params[“oauth_token”].nil?) @request_token = […]
我创建了一个rails项目,其中包含一些我想作为API执行的代码。 我正在使用rails-api gem。 该文件位于app / controllers / api / stats.rb中。 我希望能够执行该脚本并通过访问此类链接返回json输出 – http://sampleapi.com/stats/?location=USA?state=Florida 。 我应该如何配置我的项目,以便当我访问该链接时它运行我的代码?
所以我一直在尝试为Twitch设置我的聊天机器人。 我希望用户能够输入!stats然后他们会看到我的Fortnite统计数据。 他们可以使用命令和东西,这不是我遇到的问题。 我在向Fortnite Tracker API发送标题时遇到了一些麻烦。 他们想要接受这个: TRN-Api-Key: somelong-api-key-right-here在标题中有一些TRN-Api-Key: somelong-api-key-right-here 。 我试过这些方法:require(“httparty”) url = “https://api.fortnitetracker.com/v1/profile/pc/bentearzz” header = { key: “TRN-Api-Key: Somelong-api-key-here” } response = HTTParty.get(url, header: header) puts(response.body) 还有这个 require(“net/http”) require(“json”) url = “https://api.fortnitetracker.com/v1/profile/pc/bentearzz” uri = URI(url) response = Net::HTTP::Get.new(uri) response.basic_auth(“TRN-Api-Key: 7af072f0-d195-4c44-b1b4-a8838080e4c4”) JSON.parse(response) print(response) 请帮忙。
我有一个API的控制器,如下所示: def index respond_to do |format| format.json { render :json => @groups.to_json(:only => [:id, :name, :description, :created_at, :updated_at])} end end def show respond_to do |format| format.json { render :json => @group.to_json(:only => [:id, :name, :description, :created_at, :updated_at]) } end end # @todo add store to item def create if @group.save render :json => @group.to_json(:only => […]
我写了一个简单的Jekyll插件来使用twitter gem来推送我的推文(见下文)。 我想在我的开放Github网站上保留插件的ruby脚本,但是在最近对twitter API的更改之后,gem现在需要身份validation凭据。 require ‘twitter’ # Twitter API require ‘redcarpet’ # Formatting links module Jekyll class TwitterFeed true, :space_after_headers => true) ## Attempt to load credentials externally here: require ‘~/.twitter_auth.rb’ out = “” tweets = @client.user_timeline(@user) for i in 0 … @count.to_i out = out + “” + markdown.render(tweets[i].text) + ” ” + tweets[i].created_at.strftime(“%I:%M […]
我是第一次调用基于SOAP的API,我从文档中获得以下信息: 在您的客户端中,构建您的授权标头,如下所示: 1连接用户名和密码,例如:ExampleUsername:ExamplePassword 2在base 64中编码字符串,例如:RXhhbXBsZVVzZXJOYW1lOVV4YW1wbGVQYXNzd29yZA == 3在代码中,输入值为Basic的Authorization标头。 示例Web服务标头,带有编码的用户名和密码 POST https://api.five9.com/wsadmin/AdminWebService HTTP / 1.1 Accept-Encoding:gzip,deflate Content-Type:text / xml; charset = UTF-8 SOAPAction:“” 授权:基本RXhhbXBsZVVzZXJOYW1lOkV4YW1wbGVQYXNzd29yZA == 我正在使用Savongem来打电话。 在给定上述信息的情况下,如何使用Ruby 1.9.3和Savon gemvalidationAPI调用api_call ? 这就是我用来设置WSDL或client 。 client = Savon.client(wsdl: “https://api.five9.com/wsadmin/v2/AdminWebService?wsdl&user=luigi@apitest.com”)
我正在尝试使用从SOAP api获取帐户信息的Savon gem(v2)在Ruby中编写代码,但是我遇到了传递数组的问题。 CampaignIds应该是一个整数数组。 这是我的代码: client = Savon.client(wsdl: “https://api7secure.publicaster.com/Pub7APIV1/Campaign.svc?singleWsdl”) message = { “EncryptedAccountID” => api_key, “APIPassword” => api_password, “CampaignIds” => [3,4], “StartDate” => yesterday, “EndDate” => yesterday, “IncludeTests” => false } client.call(:get_comparative_report_details_data, message: message) 产生以下要求: ***** ***** 3 4 2014-01-06 2014-01-06 false 然而,如果我在SOUP UI中玩游戏,请求应如下所示: ***** ***** 3 4 2014-01-06T16:21:47-05:00 2014-01-07T16:21:47-05:00 false 有任何想法吗?