Reputation: 161
I want to call another web-api from my server with payload using post method, For example,
https://api.example.com.bd/subscription/query-base
Payload :
Content type application/json;charset=utf-8
{
"applicationId": "APP_000201",
"password": "39a8d1cb245029d0560619a2b388669c"
}
Response samples :
{
"baseSize": "0",
"version": "1.0.",
"statusCode": "S1000",
"statusDetail": "Success."
}
I want to return only baseSize that method how to do it
Upvotes: 1
Views: 2843
Reputation: 314
I'm assuming you're talking about making a request to a REST API. The way to do this in Spring is to use RestTemplate
. You will typically want to define a bean to inject the rest template into whatever class you want to make the call from. You will likely be using one of the following methods to call your API: exchange
, postForObject
, or postForEntity
.
I would recommend reading some documentation on how to use the RestTemplate before going further. Here is a good starting point. The code is in Java, but the basic idea is the same in Kotlin.
Upvotes: 1