Amazon Sagemaker:如何对 AWS SageMaker 端点请求进行身份验证
Amazon Sage Maker: How to authenticate AWS SageMaker End-Point Request
我有一个需要从 .Net 核心客户端调用的 aws sagemaker 端点,我使用了处理 SageMaker 的 AWS SDK 并提供了所需的凭证,但是,它总是说:
我们计算出的请求签名与您提供的签名不匹配。检查您的 AWS 秘密访问密钥和签名方法。有关详细信息,请参阅服务文档。
var requestBody = "{'url':'"+"https://cdn.pixabay.com/photo/2018/05/28/22/11/message-in-a-bottle-3437294_960_720.jpg" + "'}";
var request = new Amazon.SageMakerRuntime.Model.InvokeEndpointRequest()
{
EndpointName = "CG-model-v1-endpoint",
ContentType = "application/json;utf-8",
Body = new MemoryStream(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(requestBody)))
};
var awsClient = new AmazonSageMakerRuntimeClient(awsAccessKeyId: "XXXX", awsSecretAccessKey: "XXX", region: RegionEndpoint.EUCentral1);
try
{
var resposnse = await awsClient.InvokeEndpointAsync(request);
}
catch (Exception ex)
{
return ApiResponse<bool>.Create(false);
}
我发现了错误,这仅仅是因为请求 content-type,它必须是 application/json 而不是 application/json;utf-8
我有一个需要从 .Net 核心客户端调用的 aws sagemaker 端点,我使用了处理 SageMaker 的 AWS SDK 并提供了所需的凭证,但是,它总是说:
我们计算出的请求签名与您提供的签名不匹配。检查您的 AWS 秘密访问密钥和签名方法。有关详细信息,请参阅服务文档。
var requestBody = "{'url':'"+"https://cdn.pixabay.com/photo/2018/05/28/22/11/message-in-a-bottle-3437294_960_720.jpg" + "'}";
var request = new Amazon.SageMakerRuntime.Model.InvokeEndpointRequest()
{
EndpointName = "CG-model-v1-endpoint",
ContentType = "application/json;utf-8",
Body = new MemoryStream(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(requestBody)))
};
var awsClient = new AmazonSageMakerRuntimeClient(awsAccessKeyId: "XXXX", awsSecretAccessKey: "XXX", region: RegionEndpoint.EUCentral1);
try
{
var resposnse = await awsClient.InvokeEndpointAsync(request);
}
catch (Exception ex)
{
return ApiResponse<bool>.Create(false);
}
我发现了错误,这仅仅是因为请求 content-type,它必须是 application/json 而不是 application/json;utf-8