Hi Raj,
What is exactly the problem you are facing? You said you cannot connect to the new URL, but what is exactly the error?
The code seems pretty straigthforward. Bear in mind that running the code directly from C# you are running the code on a different machine, since the code excuted from an OutSystems extension runs in the server. I think we need more data to troubleshoot the issue.