Skip to content

_assetService.UploadFileAsync(query) throws Response status code does not indicate success: 400 (Bad Request) when using OAuth2 #109

@rabehaja-dept

Description

@rabehaja-dept

While using the following code block

``
try
{

            var query = new UploadQuery
            {
                Filepath = tempFilePath,
                BrandId = _brandId, // Use the first available brand for this example
                Name = asset.FileName,
                //CustomParameters = customParameters,
                OriginalFileName = asset.PhysicalFileName,
                Description = UrlEncoder.Default.Encode(asset.ProductName),
            };


            query.MetapropertyOptions = new Dictionary<string, IList<string>>
        {
            { "New_Color_code", new List<string> { asset.ColorCode } },
            { "viewType", new List<string> { asset.ViewType } },
            { "brand", new List<string> { asset.BrandName } },
            { "Collection", new List<string> { asset.Collection } },
            // { "colorCodeDescription", new List<string> { asset.ColorCodeDescription } },
            {"Asset_type", new List<string> { "Images" } },
             {"Asset_Subtype", new List<string> { asset.ViewType} },
            {"17nr",  asset.ProductID },
            {"EAN_UPC",  asset.EAN },
            // {"variantId",  asset.VariantID },
            {"Product_Name_",  new List<string> { asset.ProductName } }

        };


            //upload
             _assetService.UploadFileAsync(query).Wait();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Exception occurred while uploading to Bynder: " + ex.Message);
        }
        finally
        {
            if (File.Exists(tempFilePath))
            {
                File.Delete(tempFilePath);
            }
        }

``

I receive the following error
Response status code does not indicate success: 400 (Bad Request)

All the variables are fed to the best of my knowledge and to the extent of available documentation. Why is this throwing an issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions