C# “反弹”和“反弹”;“未授权”;调用AuthenticateWithApiKey后的AuthenticationState
我得到的结果与以下代码不一致:C# “反弹”和“反弹”;“未授权”;调用AuthenticateWithApiKey后的AuthenticationState,c#,rest,rally,C#,Rest,Rally,我得到的结果与以下代码不一致: RallyRestApi myRestApi = new RallyRestApi(); myRestApi.AuthenticateWithApiKey("<my_api_key>"); RallyRestApi myRestApi=new-RallyRestApi(); myRestApi.AuthenticateWithApiKey(“”); 大多数情况下,在上述代码运行之后,myRestApi.AuthenticationState是Ral
RallyRestApi myRestApi = new RallyRestApi();
myRestApi.AuthenticateWithApiKey("<my_api_key>");
RallyRestApi myRestApi=new-RallyRestApi();
myRestApi.AuthenticateWithApiKey(“”);
大多数情况下,在上述代码运行之后,myRestApi.AuthenticationState
是RallyRestApi.AuthenticationResult.Authenticated
,我的应用程序运行得很好。但偶尔,在运行上述代码后,myRestApi.AuthenticationState
为RallyRestApi.AuthenticationResult.NotAuthorized
。我曾尝试查看myRestApi
属性,但我没有发现调用AuthenticateWithApiKey
返回NotAuthorized
的原因。即使有,我的解决方案是什么,以便每次都能可靠地进行身份验证
提前谢谢 您需要在身份验证请求中显式地传递serverURI,而不是依赖默认值:
RallyRestApi restApi = new RallyRestApi();
restApi.AuthenticateWithApiKey("myApiKey", new Uri("https://rally1.rallydev.com"));
谢谢,@user2738882。但是,我很好奇为什么serverURI需要显式设置。。。为什么默认的rallyServer字符串不起作用?它对您有帮助吗?如果是,请接受答案。到目前为止,答案是肯定的,但由于最初的问题是间歇性的,我无法100%确认这个答案肯定解决了这个问题。无论如何,我会将此答案标记为已接受,直到它不被接受为止;)