It is not a good idea to use Postman in Java.
But you can do the same thing using Java.
First, you should call the same endpoint that Postman calls. You can use Unirest to access this endpoint.
Unirest.post("http://api.callme.com/json")
.asJson()
It is good to observe the METHOD that is called on Postman and use the same on Unirest. In the code above, I'm using the method POST.
Then, you will get a JSON object.
try this code THis is a basic code to get the data from json data and please search
Download this jar file json
How to add jar file documentation here
String url = "http//url"; //define the url here
URL obj; //making the object
obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
//add authorisation if you have any
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept-Language", "UTF-8");
int responseCode = con.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " + responseCode);
JSONObject jsonObject = new JSONObject(response.toString());
String nid = jsonObject.get("customer-id").toString();
You should have to set content type to application/json . And in your java web application side, you can fetch that json from request. If you are using servlet then you have to use request.getParameter("customer-id");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.