Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Blockchain by (4.1k points)

I am trying to create wallet on Blockchain using Ajax but I am getting "Cross-Origin Request Blocked" error. My Ajax call is:

$.ajax({
                    type: 'POST',
                    url: 'https://blockchain.info/api/v2/create_wallet',
                    data: "cors=true&email="+email+"&password="+password+"&api_code="+code,
                     dataType:'json',
crossDomain: true,
                     beforeSend:function(){


                      },
                    success: function (data) {

                    }
            });

 

When I post this I get error Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://blockchain.info/api/v2/create_wallet. This can be fixed by moving the resource to the same domain or enabling CORS.

On Blockchain they say that Some API calls are available with CORS headers if you add a cors=true parameter to the request

I have tried everything, I have tried to send this parameter as a GET as well as POST parameter, I have tried jsonp. I have also tried with the header Access-Control-Allow-Origin * but nothing seems to be working. Can anyone confirm if he managed to create blockchain wallet using Ajax call or they don't support CORS for this. Any help will be much appreciated.

Thanks

Hamza

1 Answer

0 votes
by (14.4k points)
edited by

I believe that blockchain has no support for the CORS error for the wallet API. I can say this because to me your code is correct and should execute fine. Actually, the blockchain wallet API docs do not specify calls available via CORS through the cors=true query parameter.

Know Blockchain better with Blockchain Training by Intellipaat.

Related questions

Browse Categories

...