I am trying to make a simple rest call to graphql endpoint but getting a 400 error from the server. Have been struck in this for a while.
Payload
query = "{\n" +
" lookup(dob: \"01/01\", preSsn : { ssn: \"{actualvalue}\"})\n" +
" {\n" +
" items {\n" +
" individualCrdNumber\n" +
" firstName\n" +
" middleName\n" +
" lastName\n" +
" suffixName\n" +
" }\n" +
" }\n" +
"}";
Error message: {"statusCode":400,"statusDescription":"Bad Request","message":"","messageDetails":[]}
Code:
HttpClient client = getHttpsClient();
HttpPost httpPost = new HttpPost(URL);
StringEntity input = new StringEntity(query, ContentType.APPLICATION_JSON);
httpPost.setEntity(input);
final String plainCred = "userName"+":"+"password";
final String base64Creds = Base64.getEncoder().encodeToString(plainCred.getBytes());
httpPost.addHeader("Authorization", "Basic " + base64Creds);
httpPost.addHeader("Content-Type", "application/json");
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Cache-Control", "no-cache");
HttpResponse response = client.execute(httpPost);