how do I request ESG data from java

I have got my session token (RDP Token), is any java sample to request ESG data e.g. https://api.refinitiv.com/data/environmental-social-governance/v1/views/basic?universe=IBM.N


StringBuilder url = new StringBuilder("https://api.refinitiv.com/data/environmental-social-governance/v1/views/basic?universe=IBM.N");

HttpGet request = new HttpGet(url.toString());

request.addHeader("Authorization", "Bearer " + sessionToken);

CloseableHttpClient httpClient = HttpClients.createDefault();

CloseableHttpResponse httpResponse = httpClient.execute(request);

BufferedReader reader = new BufferedReader(new InputStreamReader(

httpResponse.getEntity().getContent()));

String inputLine;

StringBuffer response = new StringBuffer();

while ((inputLine = reader.readLine()) != null) {

response.append(inputLine);

}

System.out.println(response.toString());

httpClient.close();


{"error":{"id":"107c01c3-fbfb-4217-8169-dadb2439b61d","code":"insufficient_scope","message":"access denied. Scopes required to access the resource: [trapi.data.esg.views-basic.read]. Missing scopes: [trapi.data.esg.views-basic.read]","status":"Forbidden"}}


This is my code, but I got above error

Any ideas?

Best Answer

  • nick.zincone
    nick.zincone admin
    Answer ✓

    Hi @bin0

    The above error "insufficient_scope" usually indicates that you do not have a license for the specified endpoint data - in your case ESG. As a test, you can try to retrieve ESG data from the API Playground based on the user ID you were provided in your Welcome email.

    I would recommend you contact your Refinitiv account manager to confirm whether a license to retrieve ESG has been set up.

Answers

  • bin0
    bin0 Newcomer

    Hi

    Thanks, I tried same machine ID, password and client ID by useing postman, and python sample, I got same error code, insufficient_scope.

    One question for the client ID. I use the apikey portal to generate the appKey. Do you know which account I should log in to generate the App Key, my machine ID account or my developer account. I tried to use my machineID and machine ID password but I cannot log in appkey generation portal, so I use developer account to generate appKey. is that correct.key.jpg

  • hi @bin0

    Yes, it's correct. The machine ID account cannot be used to login to generate the appkey, but the developer account can.