Hi,
May I wonder why your code is exactly like provided? Why/what were your reasons to write exactly this but not some other code?
I think that the correct way is like this:
-- Either investigate YouTrack documentation, figure out requests that must be sent to the YouTrack server in order to create an issue and provide it with an attachement, and then try to implement these requests in TestComplete; or
-- If YouTrack provides some sort of web interface or application that communicates with the server via HTTP protocol, you may use some recording proxy (e.g.: Fiddler, LoadComplete, JMeter, ...) and record the traffic generated while creating an issue and sending an attachment. Then you will have to analyse the traffic, parameterize it and, again, try to implement it with TestComplete.
P.S. I may provide you with my opinion of why things that you've mentioned do not work. But without knowing details of how your instance of YouTrack is set up and without knowing its web API this will be just a useless wild guess.