Reflexion will be End-of-life on March 31,2023. See Sophos Reflexion EoL FAQs to learn more.
Hi,
I am trying to generate the token using the URL "id.sophos.com/.../token" as a POST method. I got a successful result when requesting it with the POSTMAN tool. But when I request the same using java API it gives me "400 BAD REQUEST: "{"errorCode": "customer.validation", "message": "Bad Request"}.
I tried to request the parameters mentioned above in both encoded and non-encoded formats. It gives me the same error. Apart from that the same parameter I used in the python application also, There I got a successful result. I didn't know what is wrong with the java API.
HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); Map<String, Object> requestBody = new HashMap<>(); String apiUrl = "">id.sophos.com/.../token"; requestBody.put("grant_type", "client_credentials"); requestBody.put("scope", "token"); requestBody.put("client_secret", "xxxxxxxxxxx"); requestBody.put("client_id", "xxxxxxxxxxxxx"); URI uri = UriComponentsBuilder.fromHttpUrl(apiUrl).build().toUri(); HttpEntity<?> requestEntity = new HttpEntity<>(mapper.writeValueAsString(requestBody), headers); ResponseEntity<String> exchange = restTemplate.exchange(uri, HttpMethod.POST, requestEntity, String.class);
since it is Https did we need to add anything else?
Can u guys give me a response on this?
Hi Jinto,
Thanks for reaching out to the Sophos Community Forum.
As you're using Postman to test as well, can you use the "Code snippet" tool to copy the query Postman is running? The available options are "Java - Unirest" and "Java - OkHttp".
If this does not work for you, or if this does not fulfil requirements in your environment, please let me know.