In the browser, all these scripts are executed automatically, if you work with the site via the http-client, then you will have to execute these scripts manually.
Edit : After digging further i found the problem . I had selected "ON" in the Sandbox option in my 2captcha account. This was giving me the error
Now it works