Unpredictable text replacement

When running the following code multiple times the resulting “out.docx” file contains both “FOO” and “BAR” but sometimes only “FOO” or only “BAR”. What can I do to ensure both string replacements are carried out in all cases?

require 'aspose_words_cloud'

AsposeWordsCloud.configure do |config|
  config.client_data['ClientId'] = '...'
  config.client_data['ClientSecret'] = '...'
end

words_api = AsposeWordsCloud::WordsApi.new
local_file = File.new('test.docx', 'rb')
remote_path = 'test'
remote_name = 'remote.docx'

uf_req = AsposeWordsCloud::UploadFileRequest.new(file_content: local_file, path: "#{remote_path}/#{remote_name}")
words_api.upload_file(uf_req)

rt_param_1 = AsposeWordsCloud::ReplaceTextParameters.new({:OldValue => '<<replaceme1>>', :NewValue => 'FOO'})
rt_req_1 = AsposeWordsCloud::ReplaceTextRequest.new(name: remote_name, folder: remote_path, replace_text: rt_param_1)
bp_req_1 = AsposeWordsCloud::BatchPartRequest.new(rt_req_1)

rt_param_2 = AsposeWordsCloud::ReplaceTextParameters.new({:OldValue => '<<replaceme2>>', :NewValue => 'BAR'})
rt_req_2 = AsposeWordsCloud::ReplaceTextRequest.new(name: remote_name, folder: remote_path, replace_text: rt_param_2)
bp_req_2 = AsposeWordsCloud::BatchPartRequest.new(rt_req_2)

words_api.batch([bp_req_1, bp_req_2])

df_req = AsposeWordsCloud::DownloadFileRequest.new(path: remote_path + '/' + remote_name)
result = words_api.download_file(df_req)
File.write('out.docx', result)

@evaneykelen

We are investigating the issue and will share our findings with you. Meanwhile, please share your input document with us. It will help us to investigate and fix the issue exactly.

test.docx (12.4 KB)

@evaneykelen

Thanks for sharing the sample document. I noticed the reported issue and logged a ticket WORDSCLOUD-2011 for further investigation. We will keep you updated about the issue resolution progress within this forum thread.