1

我正在尝试更新给定用户的团队成员资格。由于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()吗?

4

0 回答 0