api – Getting error while fetching data from Java using GraphQL endpoint with query
I am unable to fetch response while trying to access GraphQL endpoint using java HTTP Post request. I am able to access it from Postman while using the same query and endpoint.
Below is my Java code and GraphQL query
HttpPost post = new HttpPost(url);
StringEntity entiry = new StringEntity(graphQlQuery, "UTF8");
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(entity);
GraphQL Query :
graphQlQuery = "{Codes(query: { startDate : "2022-09-06", endDate : "2023-03-06" sort: { startingServiceDate: DESC }, uniqueCodeLimit: 10 } ) { diagnosisCode, diagnosisCodeDescription, diagnosisCodeEffectiveDate, diagnosisCodeExpirationDate, } }";
Error :
java.lang.Exception: {"errors":["Invalid GraphQL request"],"extensions":{"errorDetails":[{"message":"Invalid GraphQL request","code":"INVALID_GRAPHQL_REQUEST","details":"failed to deserialize the request body into JSON: key must be a string at line 1 column 2"}]}}HTTP_STATUS:400
Read more here: Source link
