Original Message:
Sent: 7/26/2024 2:11:00 PM
From: Yaniv Levy
Subject: RE: Java Calling API
Thank you Luis,
This solved the issue in Java:
client.addDefaultHeader("authorization", "apiToken XXXXXXXXXXXXXXXXXX")
------------------------------
Yaniv Levy
------------------------------
Original Message:
Sent: Thu July 25, 2024 03:30 PM
From: Luis Sanchez
Subject: Java Calling API
Check the API token you're using. The ApiTokenClient class calls /api/settings/api-tokens, and the API Token you're using should have the permission "Configuration of API Tokens":
Validate with curl:
Regards,
Original Message:
Sent: 7/25/2024 11:25:00 AM
From: Yaniv Levy
Subject: RE: Java Calling API
Dear Luis
I have read the file and there is a short snippet of Java to try it out. it seems the some of the code is irrelevant.
Here is the result, Im getting an error 401 - and i was generating an API TOKEN at : https://ibmdevsandbox-instanaibm.instana.io/
private void postConstruct() {
ApiClient client = new ApiClient();
client.setBasePath("https://ibmdevsandbox-instanaibm.instana.io");
client.setDebugging(true);
client.setMaxAttemptsForRetry(5);
ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) client.getAuthentication("ApiKeyAuth");
ApiKeyAuth.setApiKey("MY___OWN___KEY");
ActionCatalogApi apiInstance = new ActionCatalogApi(client);
ApiTokenApi ata = new ApiTokenApi(client);
try {
List<ApiToken> result = ata.getApiTokens();
System.out.println(result);
} catch (Exception e) {
System.err.println("Exception when calling ActionCatalogApi#getActionByID");
System.err.println("Status code: " + e.getMessage());
e.printStackTrace();
}
}
Exception when calling ActionCatalogApi#getActionByID
Status code: 401 Unauthorized: "{"errors":["Unauthorized request"]}"
org.springframework.web.client.HttpClientErrorException$Unauthorized: 401 Unauthorized: "{"errors":["Unauthorized request"]}"
------------------------------
Yaniv Levy
Original Message:
Sent: Thu July 25, 2024 09:47 AM
From: Luis Sanchez
Subject: Java Calling API
Did you have the chance to review the README.md file of the generated project ?. It has a quite complete spec of the library and the use into a spring-boot project.
Regards,
Original Message:
Sent: 7/24/2024 8:44:00 AM
From: Yaniv Levy
Subject: Java Calling API
Hello
Im need to wrap instana Api with Java Spring boot.
So I used: https://instana.github.io/openapi/
java -jar openapi-generator-cli.jar generate -i https://instana.github.io/openapi/openapi.yaml -g java -o pkg/instana/openapi --skip-validate-spec -p dateLibrary=java8,hideGenerationTimestamp=true --library resttemplate
and now i need to start coding the framework.
I cannot find any documents, any code examples on how execute the java ?
In case you have some code examples how to execute api ?
Thanks.
------------------------------
Yaniv Levy
------------------------------