Need a script (since internal tools of 1C do not work) that will deliver an import file via API to the Prom.ua website. There is a script I wrote, but it does not work, maybe you will find the error:
Function ImportProductsPromUaViaScript(AuthorizationToken, PathToXLSXFile, ImportSettings)
Dim WshShell, Command, ExecutionResult;
// Path to VBScript file
// Make sure that import_prom.vbs is located in an accessible place,
// or specify its full path.
If FSO.FileExists(DirectoryB() + "import_prom.vbs") = 1 Then
PathToScript = DirectoryB() + "import_prom.vbs"; // Change to the actual path!
Else
MsgBox("Script not found " + DirectoryB() + "import_prom.vbs");
Return 0;
End If;
// Escape quotes in JSON string for command line
// (replace " with \\" or "")
EscapedSettings = StrReplace(ImportSettings, """", \"\");
// Form the command to run VBScript
// Use cscript.exe for console output
Command = "cscript.exe //NoLogo \"" + PathToScript + "\" \"" + AuthorizationToken + "\" \"" + PathToXLSXFile + "\" \"" + EscapedSettings + "\"";
Try
WshShell = CreateObject("WScript.Shell");
// Run the script and wait for it to finish
// 0 - window hidden, True - wait for completion
ExecutionResult = WshShell.Run(Command, 0, 1);
// If the script outputs result via WScript.Echo,
// then it needs to be redirected to a file or stdout for 1C to read.
// Usually, to get output, redirect it to a temporary file
// or run the script with PowerShell, which can capture stdout.
// Simple option: do not get output, only check the exit code.
// If server response is needed, VBScript should write it to a file.
If ExecutionResult = 0 Then // Usually 0 indicates success
Return "Import script completed successfully (code: " + ExecutionResult + ").";
Else
Return "Import script finished with an error (code: " + ExecutionResult + "). Check the script logs.";
End If;
Catch
MsgBox("Error running external script: " + ErrorDescription());
Return "";
End Try;
EndFunction
Procedure ExampleImport() Export
Dim Token, PathToFile, Settings, Result;
PathToFile = "D:\Obmen\Import_Prom.xlsx";
Token = STrim(Constance.TokenProm);
Settings = "{ ""force_update"": false, ""only_available"": false, ""mark_missing_product_as"": ""none"", ""updated_fields"": [ ""price"", ""presence"", ""name"", ""sku"", ""images_urls"", ""quantity_in_stock"", ""description"", ""group"", ""keywords"", ""attributes"", ""discount"", ""labels"", ""gtin"", ""mpn"", ""translations"" ] }";
Result = ImportProductsPromUaViaScript(Token, PathToFile, Settings);
MsgBox(Result);
EndProcedure
Script in file