I am going to merge this thread into this:
The summary here is that by moving this to a gateway script (as opposed to running it all from the script console) overcomes the error named:
unable to find valid certification path to requested target
Thanks,
Nick