Hi Team,
We are trying to do bulk upload using the api createBulkProductUploadJob, now the problem which we are facing is when we are manually uploading our excel sheet that is happening successfully but the same excel sheet when i am trying to upload via api it is showing in pending state in the FP extension
@GetMapping(“/createBulkProductUploadJob”)
public CatalogPlatformModels.BulkResponse createBulkProductUploadJob() throws FDKServerResponseError, FDKException, IOException, ExecutionException, InterruptedException {
PlatformClient platformClient = extensionService.getPlatformClient(“38”);
CatalogPlatformModels.BulkJob bulkJob = new CatalogPlatformModels.BulkJob();
bulkJob.setCompanyId(38);
bulkJob.setTemplateTag(“jewellery”);
// bulkJob.setFilePath(“/Users/hitesh.pant/Downloads/sample_csv_upload_catalogue_1.csv”);
// bulkJob.setFilePath(“https://cdn.pixelbin.io/v2/yellow-queen-0c3fa9/gly4zC/wrkr/sngz0/test/general/free/original/sample_csv_upload_catalogue_1.csv”);
bulkJob.setFilePath(uploadProcess(“/Users/abhishek.shaw/Downloads/”, “Correct_sample_catalogue_file_1.xlsx”).get());
CatalogPlatformModels.BulkResponse resp = null;
try {
resp = platformClient.catalog.createBulkProductUploadJob(bulkJob);
// resp = platformClient.catalog.uploadBulkProducts(“jewellery”,“Standard”, bulkJob);
} catch (FDKServerResponseError e) {
throw new RuntimeException(e);
} catch (FDKException e) {
throw new RuntimeException(e);
}
return resp;
}
public CompletableFuture uploadProcess(String localFilPath, String localFileName)
throws FDKServerResponseError, FDKException, IOException {
PlatformClient platformClient = extensionService.getPlatformClient(“38”);
// START UPLOAD STEP -
FileStoragePlatformModels.StartResponse startUploadResponse = null;
FileStoragePlatformModels.CompleteResponse completeUploadResponse = null;
FileStoragePlatformModels.StartRequest body = new FileStoragePlatformModels.StartRequest();
//body.setContentType(“application/pdf”);
body.setContentType(“application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”);
body.setSize(500);
// body.setFileName(“sample_csv_upload_catalogue_10.csv”);
body.setFileName(localFileName);
startUploadResponse = platformClient.fileStorage.startUpload(“test”, body);
String url = startUploadResponse.getUpload().getUrl();
// PUT API CALL STEP -
// AwsApiList awsApiList = getOrGenerateAwsApiList(url);
AwsApiList awsApiList = getOrGenerateAwsApiList("https://cdn.pixelbin.io/v2/yellow-queen-0c3fa9/gly4zC/wrkr/");
// File file = new File(“/Users/hitesh.pant/Downloads/sample_csv_upload_catalogue_10.csv”);
File file = new File(localFilPath+localFileName);
byte[] bytes = Files.readAllBytes(file.toPath());
String cdnUrl = startUploadResponse.getCdn().getUrl();
String uploadUrl = startUploadResponse.getUpload().getUrl();
if (StringUtils.isNotEmpty(cdnUrl) && StringUtils.isNotEmpty(uploadUrl)) {
String contentTypeFromResponse =
StringUtils.isNotEmpty(startUploadResponse.getContentType())
? startUploadResponse.getContentType()
: “”;
awsApiList
.updateAWSMedia(
contentTypeFromResponse,
uploadUrl,
okhttp3.RequestBody.create(okhttp3.MediaType.parse(contentTypeFromResponse), bytes))
.execute();
// COMPLETE UPLOAD STEP -
FileStoragePlatformModels.StartResponse body2 = new FileStoragePlatformModels.StartResponse();
body2.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
body2.setCdn(startUploadResponse.getCdn());
body2.setUpload(startUploadResponse.getUpload());
body2.setFilePath(startUploadResponse.getFilePath());
body2.setSize(startUploadResponse.getSize());
body2.setFileName(startUploadResponse.getFileName());
body2.setMethod(startUploadResponse.getMethod());
body2.setNamespace(startUploadResponse.getNamespace());
body2.setOperation(startUploadResponse.getOperation());
body2.setTags(startUploadResponse.getTags());
FileStoragePlatformModels.CompleteResponse completeResponse =
platformClient.fileStorage.completeUpload("test", body2);
return CompletableFuture.completedFuture(completeResponse.getCdn().getUrl());
}
return null;
}
above is my sample code which i have written and with the help of which i am trying to perform bulk operation.
Note :- With the same process i am able to upload inventory excel sheet bulk one .
So please kindly suggest me where i am doing wrong