使用 .NET 库时向 Amazon SNS 主题添加权限时出错
尝试使用 AWS SDK for .NET/1.1.0.1 添加对 Amazon SNS 主题的权限时代码类似如下:
AddPermissionRequest request = new AddPermissionRequest()
.WithActionNames(new[] { "Publish" })
.WithAWSAccountIds(new[] { "xxx" })
.WithLabel("PrincipleAllowControl")
.WithTopicArn(resourceName);
client.AddPermission(request);
返回以下错误信息:
<ErrorResponse xmlns=" http://sns.amazonaws.com/doc/2010-03-31/">
<Error>
<Type>Sender</Type>
<Code>ValidationError</Code>
<Message>2 validation errors detected: Value null at 'actionName' failed to satisfy constraint: Member must not be null; Value null at 'aWSAccountId' failed to satisfy constraint: Member must not be null</Message>
</Error>
<RequestId>45054159-e46b-11df-9b30-693941920fe7</RequestId>
</ErrorResponse>
When attempting to add permissions to an Amazon SNS topic using the AWS SDK for .NET/1.1.0.1 using code similar to the following:
AddPermissionRequest request = new AddPermissionRequest()
.WithActionNames(new[] { "Publish" })
.WithAWSAccountIds(new[] { "xxx" })
.WithLabel("PrincipleAllowControl")
.WithTopicArn(resourceName);
client.AddPermission(request);
The following error message is returned:
<ErrorResponse xmlns=" http://sns.amazonaws.com/doc/2010-03-31/">
<Error>
<Type>Sender</Type>
<Code>ValidationError</Code>
<Message>2 validation errors detected: Value null at 'actionName' failed to satisfy constraint: Member must not be null; Value null at 'aWSAccountId' failed to satisfy constraint: Member must not be null</Message>
</Error>
<RequestId>45054159-e46b-11df-9b30-693941920fe7</RequestId>
</ErrorResponse>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新 - 此问题已在最新版本的 .NET API 中得到解决,因此仍然遇到此问题的任何人都应升级到 1.1.1 版本。
我花了一段时间才弄清楚发生了什么,最终不得不使用 HTTP 版本的客户端以及 Wireshark< /a> 来观察发生了什么,但 AWS SDK for .NET/1.1.0.1 中似乎存在错误。当我使用 AWS SDK for Java 编写类似的函数时,事实证明工作正常,以下是该代码的一小块:
通过 Wireshark 观察发生的情况,结果如下,为了清晰起见,进行了一些小的审查和编辑:
如您所见,适用于 .NET 的 AWS 开发工具包正在使用 AWSAccountIds 和 ActionNames 进行调用,而不是使用 AWSAccountId 和AWS Java SDK 使用的 ActionName,它解释了返回的错误消息。
目前,除了不在 .NET 应用程序中使用该命令并编写自己的代码来进行调用之外,似乎没有什么可以做的。如果幸运的话,这个问题将在 SDK 更新中得到解决。
Update - This has been resolved in the latest version of the .NET API so anyone still encountering this problem should upgrade to the 1.1.1 version of the API.
Took me awhile to figure out what was going on and I ended up having to use the HTTP version of the clients as well as Wireshark to watch what was happening, but it appears that there is a bug in AWS SDK for .NET/1.1.0.1. When I wrote a similar function using the AWS SDK for Java things proved to work fine, the following is a small block of that code:
Watching what was happening via Wireshark turned up the following, with some minor censoring and editing for clarity:
As you can see, the AWS SDK for .NET is making a call using AWSAccountIds and ActionNames as opposed to AWSAccountId and ActionName used by the AWS Java SDK which explains the error message that was returned.
For now there doesn't appear to be much that can be done about it short of not using the command in .NET applications and writing your own code to make the call. With any luck this will be fixed in an update to the SDK.