我正在尝试更新给定用户的团队成员资格。由于TeamMemberships
是来自User
的可修改集合,因此我尝试在我的代码中使用它。
def build_query(type,fetch,project_ref,string)
query = RallyAPI::RallyQuery.new()
query.type = type
query.fetch=fetch
query.query_string=string
result = @rally.find(query)
return result
end
def start
@projectName = "Rohan-test"
username = "Rohan Dalvi"
currentTeamMembership = get_current_team_membership("Rohan Dalvi")
puts "Current Team Membership: #{currentTeamMembership.inspect}"
current = currentTeamMembership.first
puts current["TeamMemberships"]
h_array = Array.new
h = {}
h["TeamMemberships"] = current["TeamMemberships"]
h["_ref"] = "/project/#{get_project_ref}"
h_array.push(current["TeamMemberships"])
h_array.push(h["_ref"])
final = {}
final["TeamMemberships"] = h_array
@rally.update("user",current["_ref"],final)
puts "Done"
#newTeam["_ref"] = get_project_ref
end
def get_current_team_membership(displayname)
#get current team membership for a user
result = build_query("User","DisplayName,TeamMemberships","","(DisplayName = \"#{displayname}\")")
if(result.length!=0)
return result
else
puts "There was some problem getting team membership for this user"
end
end
def get_project_ref
result = build_query("Project","Name,Description,ObjectID","","(Name = \"#{@projectName}\")")
puts result.inspect
if(result.length==1)
project = result.first
return project["ObjectID"]
else
puts "There was some problem getting the project"
end
end
start
我收到错误消息:
Error on request - https://rally1.rallydev.com/slm/webservice/v2.0/user/13843362286 -
{:errors=>["Not authorized to perform action: Invalid key"], :warnings=>[]}
使用@rally.update()
时发送哈希值以便更新的方式有什么问题吗?