Amazon-SP-API-CSharp icon indicating copy to clipboard operation
Amazon-SP-API-CSharp copied to clipboard

receiving report file into Windows Temp folder which is not accessible, please suggest what to do

Open asifiq2000 opened this issue 2 years ago • 1 comments

Hi @abuzuhri

I am Facing an issue with the report file which is being received into the C:/Windows/Temp folder but this folder is not accessible so despite receiving the file I am unable to access the file or read the file content. so requesting you to please suggest how can I receive the file in my desired location or any drive like d:\ or e:\ so that I can easily access it. or suggest the other way to access it. Note: The data I am importing is more than 50k or 100k

e.g. ReportManager reportManager = new ReportManager(amazonConnection); var products = reportManager.GetProducts(); //GET_MERCHANT_LISTINGS_ALL_DATA

so when using above code its getting timed out hence I am trying to import the file which is faster than this. Kindly reply me ASAP.

Below is my webapi method which is returning me the received report file path

[HttpGet("GetMerchantListingsReportFile")]
public string GetMerchantListingsReportFile(string mRefreshToken, string mClientId, string mClientSecret)
{
    AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential()
    {
        AccessKey = "XXXXXXXXXXXXXX",
        SecretKey = "XXXXXXXXXXXXXX",
        RoleArn = "XXXXXXXXXXXXXX",
        ClientId = mClientId,
        ClientSecret = mClientSecret,
        RefreshToken = mRefreshToken,
        MarketPlace = MarketPlace.GetMarketPlaceByID("ATVPDKIKX0DER"),
    });
    var parameters = new ParameterCreateReportSpecification();
    parameters.reportType = ReportTypes.GET_MERCHANT_LISTINGS_ALL_DATA;

    parameters.marketplaceIds = new MarketplaceIds();
    parameters.marketplaceIds.Add("ATVPDKIKX0DER");

    parameters.reportOptions = new FikaAmazonAPI.AmazonSpApiSDK.Models.Reports.ReportOptions();

    var reportId = amazonConnection.Reports.CreateReport(parameters);

    var filePath = string.Empty;
    string ReportDocumentId = string.Empty;

        while (string.IsNullOrEmpty(ReportDocumentId))
        {
            var reportData = amazonConnection.Reports.GetReport(reportId);
            if (!string.IsNullOrEmpty(reportData.ReportDocumentId))
            {
                filePath = amazonConnection.Reports.GetReportFile(reportData.ReportDocumentId);
                break;
            }
        }
        return filePath;
        
}

asifiq2000 avatar Nov 09 '23 20:11 asifiq2000

Hi,

result of: filePath (= amazonConnection.Reports.GetReportFile(reportData.ReportDocumentId);) is string tempFilePath = Path.Combine(Path.GetTempPath() + fileName); (ReportService.cs) => Path.GetTempPath() = //Returns the path of the current user's temporary folder. usually it should be this path: C:\Users[WindowsUsername]\AppData\Local\Temp See Windows Settings - System Variables maybe this will help you

sat-it avatar Jan 12 '24 17:01 sat-it

will try in future use memory

abuzuhri avatar Jul 01 '25 17:07 abuzuhri