public class JsonRestClient extends Object
| Modifier and Type | Field and Description |
|---|---|
protected com.fasterxml.jackson.databind.ObjectMapper |
mapper |
| Constructor and Description |
|---|
JsonRestClient(String apiUrl,
ServiceBinding binding,
CdsProperties.ConnectionPool connectionPool,
com.sap.cloud.sdk.cloudplatform.connectivity.OnBehalfOf onBehalfOf)
Creates the json rest client.
|
JsonRestClient(String apiUrl,
ServiceBinding binding,
com.sap.cloud.sdk.cloudplatform.connectivity.OnBehalfOf onBehalfOf)
Creates the json rest client.
|
| Modifier and Type | Method and Description |
|---|---|
com.fasterxml.jackson.databind.JsonNode |
deleteRequest(String path)
Performs a HTTP DELETE request and returns the JSON response.
|
com.fasterxml.jackson.databind.JsonNode |
getRequest(String path)
Performs a HTTP GET request and returns the JSON response.
|
int |
getRequestWithOnlyResponseCode(String path)
Performs a HTTP GET request and returns the response code only.
|
com.fasterxml.jackson.databind.JsonNode |
postRequest(String path,
com.fasterxml.jackson.databind.JsonNode data)
Performs a HTTP POST request and returns the JSON response.
|
com.fasterxml.jackson.databind.JsonNode |
postRequest(String path,
String data,
Map<String,String> headers)
Performs a HTTP POST request and returns the JSON response.
|
com.fasterxml.jackson.databind.JsonNode |
putRequest(String path,
com.fasterxml.jackson.databind.JsonNode data)
Performs a HTTP PUT request and returns the JSON response.
|
public JsonRestClient(String apiUrl, ServiceBinding binding, com.sap.cloud.sdk.cloudplatform.connectivity.OnBehalfOf onBehalfOf)
apiUrl - api urlbinding - service bindingonBehalfOf - on behalf of OnBehalfOfpublic JsonRestClient(String apiUrl, ServiceBinding binding, CdsProperties.ConnectionPool connectionPool, com.sap.cloud.sdk.cloudplatform.connectivity.OnBehalfOf onBehalfOf)
apiUrl - api urlbinding - service bindingconnectionPool - the CdsProperties.ConnectionPool settingsonBehalfOf - on behalf of OnBehalfOfpublic com.fasterxml.jackson.databind.JsonNode getRequest(String path) throws IOException
path - destination URL pathIOException - in case of a problem or the connection was abortedJsonRestClientResponseException - in case when the response HTTP is not 2xxpublic int getRequestWithOnlyResponseCode(String path) throws IOException
path - destination URL pathIOException - in case of a problem or the connection was abortedpublic com.fasterxml.jackson.databind.JsonNode deleteRequest(String path) throws IOException
path - destination URL pathIOException - in case of a problem or the connection was abortedJsonRestClientResponseException - in case when the response HTTP is not 2xxpublic com.fasterxml.jackson.databind.JsonNode putRequest(String path, com.fasterxml.jackson.databind.JsonNode data) throws IOException
path - destination URL pathdata - JSON request bodyIOException - in case of a problem or the connection was abortedJsonRestClientResponseException - in case when the response HTTP is not 2xxpublic com.fasterxml.jackson.databind.JsonNode postRequest(String path, com.fasterxml.jackson.databind.JsonNode data) throws IOException
path - destination URL pathdata - JSON request bodyIOException - in case of a problem or the connection was abortedJsonRestClientResponseException - in case when the response HTTP is not 2xxpublic com.fasterxml.jackson.databind.JsonNode postRequest(String path, String data, Map<String,String> headers) throws IOException
path - destination URL pathdata - plain string request bodyheaders - additional request headersIOException - in case of a problem or the connection was abortedJsonRestClientResponseException - in case when the response HTTP is not 2xxCopyright © 2023. All rights reserved.