How to invoke 3rd part REST API using AEM sling servlet
Hi,
I have a requirement to invoke the client service using rest api. 3 different post is used to insert a data, read the data and delete the data and the params accordingly. I need to get the response in json format when we are reading the data and a success msg for insert and delete. How to invoke the client service and get the response using the url, params, headers(api key)?
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(siteService.getAwsUrl());
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("userid", userId));
params.add(new BasicNameValuePair(URL, bookmarkUrl));
params.add(new BasicNameValuePair(ACTION, action));
params.add(new BasicNameValuePair(SITECODE, siteCode));
params.add(new BasicNameValuePair(CATEGORY, category));
params.add(new BasicNameValuePair(TITLE, title));
httpPost.setEntity(new UrlEncodedFormEntity(params));
List<Header> headerList = siteService.getHeaders();
Header[] headers = headerList.toArray(new Header[0]);
httpPost.setHeaders(headers);
CloseableHttpResponse jsonResponse = client.execute(httpPost);
the response is giving status code as 400.
Thank you

