1. I disagree with the previous response that the Authenticated User role needs to be Admin. This is not true. I searched through the Admin and Scripting guides and could not find where this is stated. So I tested it. Turns out, the Agent role is able to upload successfully, once authenticate. ...and you really don't want to write a script with the Admin user and PIN (or Password) exposed in plain text--this is a bad practice from a security perspective [IMHO]). Now, there is a way to "hide" this, but that is outside the scope of this reply.
2. You were really close to getting this working!! You have an order of operations issue to resolve... Here's my sample script I wrote that does very close to the same thing for this section of the script:
Transform, Create, Upload
Transform Doc StepCreate XML Doc StepUpload Doc Step
Sample Transform Template:
Sample Template - XML
Final XML Document Uploaded:
Final Uploaded XML Doc
Again, my Authorized User is an Agent:
Hope this helps.