tsibelman / aws-signer-v4-dot-net

Sign HttpRequestMessage using AWS Signature v4 using request information and credentials.
Apache License 2.0
72 stars 27 forks source link

Content Type not Tracking #40

Open taylorreinerfacteus opened 1 year ago

taylorreinerfacteus commented 1 year ago

Hey Y'all,

When I use the signer on the new Bedrock API, I get an error back about the content type being incorrect. It's expecting "application/json" and it works with this type in Postman, but for some reason it isn't working with the signer.

Below is the code where I'm setting the type in the request's Content, like your example. But with the below code I get back: "message": "The provided Content Type is invalid or not supported for this model", which is the behaviour received in Postman when I change the type from json to something else, like text.

This may be a Bedrock issue, but wondering if this issue has been tracked before.

Thanks!

var signer = new AWS4RequestSigner(_titanAccessKey, _titanSecretKey);
var request = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("https://bedrock.us-west-2.amazonaws.com/model/amazon.titan-tg1-large/invoke"),
    Content = new StringContent(promptJson, Encoding.UTF8, "application/json")
};

request = await signer.Sign(request, "bedrock", "us-west-2");

var client = new HttpClient();
var response = await client.SendAsync(request);
var resultString = await response.Content.ReadAsStringAsync();
tsibelman commented 12 months ago

Sorry, I no longer actively maintain this project. I recommend switching to alternative packages.

BlockchainPunks commented 10 months ago

library works - thank you