When accessing WSO2 DAS using REST api using jersey java rest client im getting response as unsupported media type with response status 415 with response
InboundJaxrsResponse{context=ClientResponse{method=POST, uri=https://localhost:9443/analytics/search, status=415, reason=Unsupported Media Type}}
the client source below. Can anyone help on this issue.
package com.rilfi.research.c2c.das.rest.client;
import org.glassfish.jersey.SslConfigurator;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import javax.net.ssl.SSLContext;`enter code here`
import javax.ws.rs.client.*;
import javax.ws.rs.core.*;
public class DasClientApp {
public static void main(String[] args) {
SslConfigurator sslConfig = SslConfigurator.newInstance()
.trustStoreFile("./client-truststore.jks")
.trustStorePassword("wso2carbon")
.keyStoreFile("wso2carbon.jks")
.keyPassword("wso2carbon");
SSLContext sslContext = sslConfig.createSSLContext();
Client client = ClientBuilder.newBuilder().sslContext(sslContext).build();
WebTarget webTarget = client.target("https://localhost:9443").path("analytics/search");
MultivaluedMap<String, String> formData = new MultivaluedHashMap<String, String>();
formData.add("tableName", "V1SALEFULL3");
formData.add("query", "product:phone");
formData.add("start", "0");
formData.add("count", "10");
Response response = webTarget.request(MediaType.APPLICATION_JSON).post(Entity.form(formData));
System.out.println(response.getStatus());
System.out.println(response.readEntity(String.class));
System.out.println(response);
}
}
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic YWRtaW46YWRtaW4=" -v https://localhost:9443/analytics/search -d '{"tableName":"ORG_WSO2_DAS_SAMPLE_SMART_HOME_DATA", "query":"state:Texas", "start":0, "count":3}' -k- Abimaran Kugathasan