using Instamojo rest api with Spring RestTemplate class -
unable make payment request on instamojo using instamojo rest api getting bad request(400), unable identify why getting 400 error. using spring resttemplate class make post request on instamojo. below display code using:
resttemplate resttemplate = new resttemplate(); map<string,object> requestbody = new hashmap<string, object>(); requestbody.put("amount", "10000.00"); requestbody.put("purpose", "just_testing_purpose"); requestbody.put("buyer_name", "adityapandey"); requestbody.put("email", "robust_aditya95@xyz.com"); requestbody.put("phone", "+919634222331"); requestbody.put("redirect_url", "www.imthebest.in"); requestbody.put("webhook", ""); requestbody.put("allow_repeated_payments", false); requestbody.put("send_email", false); requestbody.put("send_sms", false); httpheaders headers = new httpheaders(); headers.setcontenttype(mediatype.application_json); headers.set("x-api-key", "me6a901b073db4715a9c540fa00af81"); headers.set("x-auth-token", "k3c88da2cda6f89462d6002c9d24e80"); httpentity<string> request = new httpentity<string>(requestbody.tostring(), headers); httpentity<string> response = resttemplate.exchange("https://www.instamojo.com/api/1.1/payment-requests/", httpmethod.post, request, string.class); logger.info("mailresponse "+ response);
there problem requestbody
data. redirect_url
field value must http
or https
, making change not getting 400 error anymore:
requestbody.put("redirect_url", "http://www.imthebest.in")
Comments
Post a Comment