Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# “反弹”和“反弹”;“未授权”;调用AuthenticateWithApiKey后的AuthenticationState_C#_Rest_Rally - Fatal编程技术网

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%确认这个答案肯定解决了这个问题。无论如何,我会将此答案标记为已接受,直到它不被接受为止;)