Aws-sdk-cpp: C++ UWP S3 UPLOAD FILE GETS ERROR: Unable to parse ExceptionName: BadRequest Message: An error occurred when parsing the HTTP request.

Created on 12 Jan 2021  路  3Comments  路  Source: aws/aws-sdk-cpp

When i tryin to upload a file to a s3's bucket via UWP application, im getting the error: Unable to parse ExceptionName: BadRequest Message: An error occurred when parsing the HTTP request.

im searching a lot, but dont find any fix, can help? :/

my upload function:

{
Aws::Client::ClientConfiguration config;
config.region = Aws::Region::SA_EAST_1;

Aws::S3::S3Client s3_client(credentials, config);

Aws::S3::Model::PutObjectRequest request;
request.SetBucket(bucketName);
request.SetKey(objectKey);

std::shared_ptr<Aws::IOStream> input_data =
    Aws::MakeShared<Aws::FStream>("SampleAllocationTag",
        objectName.c_str(),
        std::ios_base::in | std::ios_base::binary);

request.SetBody(input_data);

Aws::S3::Model::PutObjectOutcome outcome =
    s3_client.PutObject(request);

if (outcome.IsSuccess()) return true;

else
{
    std::string sToConvert = outcome.GetError().GetMessage();
    std::wstring w_str = std::wstring(sToConvert.begin(), sToConvert.end());
    const wchar_t* w_chars = w_str.c_str();
    Windows::UI::Popups::MessageDialog msg(ref new Platform::String(w_chars));
    msg.Title = "Database Error";
    msg.ShowAsync();
    return false;
}

}

guidance response-requested

Most helpful comment

Hi @lucoiso ,
The error message is kind of generic.... Could you provide the trace level log of this operation? Remember to remove sensitive information from them before uploading them though(Such as credentials or keys).

To activate logging add:

    Aws::SDKOptions options;
    options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
    Aws::InitAPI(options);

All 3 comments

Hi @lucoiso ,
The error message is kind of generic.... Could you provide the trace level log of this operation? Remember to remove sensitive information from them before uploading them though(Such as credentials or keys).

To activate logging add:

    Aws::SDKOptions options;
    options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
    Aws::InitAPI(options);

鈿狅笍COMMENT VISIBILITY WARNING鈿狅笍

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

The problem was access to the file blocked by Windows security factors, to solve the problem of copying the file to the application folder and controlling the streams of that file.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aramesh7 picture aramesh7  路  5Comments

atlascoder picture atlascoder  路  6Comments

falken42 picture falken42  路  5Comments

nicolasbonnard picture nicolasbonnard  路  4Comments

ferrouswheel picture ferrouswheel  路  8Comments