表示されるエラーは、WS API の v2.0 に固有のものです。WS API ドキュメントの Authorization セクションを参照してください。v2.0 では、Create および Update 要求を承認するためにセキュリティ トークンが必要です。
たとえば、更新または作成 URL を使用してアーティファクトを更新または作成する場合、最初にセキュリティ トークンを取得する必要があります。
このエンドポイントを使用してセキュリティ トークンを取得します。
`https://rally1.rallydev.com/slm/webservice/v2.0/security/authorize`
応答:
{"OperationResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [], "Warnings": [], "SecurityToken": "6a4b8....."}}
役職
`https://rally1.rallydev.com/slm/webservice/v2.0/HierarchicalRequirement/create?key=6a4b8...`.
ただし、rally_api gem 0.9.20 では透過的であり、トークンを明示的に要求する必要はありません。
カスタム フィールドが更新される例を次に示します。
require 'rally_api'
#Setup custom app information
headers = RallyAPI::CustomHttpHeader.new()
headers.name = "edit custom field"
headers.vendor = "Nick M RallyLab"
headers.version = "1.0"
# Connection to Rally
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "user"
config[:password] = "secret"
config[:workspace] = "W"
config[:project] = "P"
config[:version] = "v2.0"
config[:headers] = headers #from RallyAPI::CustomHttpHeader.new()
@rally = RallyAPI::RallyRestJson.new(config)
query = RallyAPI::RallyQuery.new()
query.type = :defect
query.fetch = "Name,FormattedID,CreationDate,Owner,UserName,c_MyCustomField"
query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1111.js" }
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/2222.js" }
query.page_size = 200 #optional - default is 200
query.limit = 1000 #optional - default is 99999
query.project_scope_up = false
query.project_scope_down = true
query.order = "Name Asc"
query.query_string = "(FormattedID = DE13)"
results = @rally.find(query)
results.each do |d|
puts "MyCustomField: #{d["c_MyCustomField"]}"
d.read
field_updates = {"c_MyCustomField" => "new text goes here"}
d.update(field_updates)
puts "MyCustomField: #{d["c_MyCustomField"]}"
end