The Flutterwave Developer Documentation

We have put together comprehensive guidelines and documentation to help you get right into integrating any of our products quickly. You can also get support when you need help!

API Documentation    API Reference
Ask A Question

Questions

5

This my fist time calling an API in Android Studio; could someone help me make a successful call with the below code

buttonReg = (Button) findViewById(R.id.butttonReg); editEmail = (EditText) findViewById(R.id.edittEmail); buttonReg.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final RequestQueue queue = Volley.newRequestQueue(Create_Account.this); String url = "https://api.flutterwave.com/v3/virtual-account-numbers"; StringRequest postRequest=new StringRequest(Request.Method.POST,url,new Response.Listener<String>() { @Override public void onResponse(String response) { Toast.makeText(Create_Account.this,response,Toast.LENGTH_SHORT); queue.stop(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { Toast.makeText(Create_Account.this,volleyError.toString(),Toast.LENGTH_SHORT); volleyError.printStackTrace(); queue.stop(); } }){ @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String,String> params=new HashMap<String,String>(); params.put("email",editEmail.getText().toString()); params.put("is_permanent", "true"); return params; } @Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> headers = new HashMap<>(); String auth = "Bearer FLWSECK_TEST-de779f952d83f8896bc8957d5666000b-X"; headers.put("Content-Type", "application/json"); headers.put("Authorization", auth); return headers; } }; queue.add(postRequest);

Posted by Samir musa 6 months ago