Cadet 1st Class
Cadet 1st Class
2505 views

SDK Issues

Hello,

I'm using the Java SDK to authenticate and retrieve the entity lists.  I can authenticate with the server but when I execute this line:

octane.entityList("defects").get().execute();
or
octane.entityList("tests").get().execute();

I get this error:

com.hpe.adm.nga.sdk.exception.OctaneException: 404 Not Found
{"errorMessage":"No user was found"}

Any help would be greatly appreciated as I'm currently evaluating this for a client of mine.  Thanks!

0 Likes
12 Replies
Micro Focus Expert
Micro Focus Expert

using same integration user and same integration password in the interactive client,interactive-client.png

Are you able to defects, or does it fail with same error ?

0 Likes
Micro Focus Expert
Micro Focus Expert

Hi

Can you add the complete code snippet that you use to authenticate (you can * out the authentication details) and then connect to octane?

Spencer

Cadet 1st Class
Cadet 1st Class

Hi,

Thanks for getting back to me.  Using the Interactive API, it works fine with my username/secret auth info.  I do get a 200 ack response.

0 Likes
Cadet 3rd Class
Cadet 3rd Class

Hello, thanks for your response.

Here's the code snipped we're using to authenticate and retrieve a list of "defects".

    public void getEntity() {
// 1) API Key
Authentication clientAuthentication = new SimpleClientAuthentication("**", "**");

// get instance of Octane Builder
final Octane.Builder octaneBuilder = new Octane.Builder(clientAuthentication);

// now we can add the server
octaneBuilder.Server("*");

// the sharedspace
octaneBuilder.sharedSpace(1001);
// the workspace
octaneBuilder.workSpace(1002);

Octane octane = octaneBuilder.build();

// octane.entityList("defects").get().limit(2).execute();
octane.entityList("defects").get().execute();
//

}
0 Likes
Cadet 3rd Class
Cadet 3rd Class

The exact response from the HTTP request to retrieve "defects" is the following: 

Exception in thread "main" com.hpe.adm.nga.sdk.exception.OctaneException: 404 Not Found
{"errorMessage":"No user was found"}

0 Likes
Micro Focus Expert
Micro Focus Expert

Hi

Is the server URL correct? What about the shared space and workspace id?

Spencer

0 Likes
Cadet 1st Class
Cadet 1st Class

Thanks very much for your help.  We discovered a typo in the shared space ID that solved the problem.

0 Likes
Micro Focus Expert
Micro Focus Expert

You are welcome.  If you have any feedback regarding the SDK we would love to hear it wither here or on the SDK's GitHub page.

Thanks

Spencer

0 Likes
Cadet 1st Class
Cadet 1st Class

Hi ,

1) I Have a issue Regarding updating the status of a defect.Can It be done using ALM Octane java SDK if not is there any other way to update it

As per my understating and observation I am considering phase of a defect as status of that defect and am trying to update it so that I can change the status of the defect from one one status to other status

 2) And I also need a clarification on .Is there a way to get the next possible phases of a specific defect using sdk or any other way 

Below is my code which i used for updating phase entity

EntityList.Entities entity = octane.entityList("defects").at(3011);
GetEntity get1 = entity.get();
EntityModel entityModel = get1.execute();
FieldModel<EntityModel> phaseField =
new ReferenceFieldModel("phase",
new EntityModel(new HashSet<>(Arrays.asList(
new StringFieldModel("type", "phase"),
new StringFieldModel("id", "phase.defect.new")
))));
Set<FieldModel> entityFields = new HashSet<>(Arrays.asList(phaseField));
entityModel.setValues(entityFields);
entity.update().execute();

feel free to corret me if I am wrong in my understanding or code as I'm currently Developing this for a client of mine.  

Thanks

Mahesh

Tags (1)
0 Likes
Micro Focus Expert
Micro Focus Expert

Hi Mahesh

You can certainly use the SDK for this purpose.  However I would recommend using the typed version.  This means that you can refer to defects as Defect object and the possible phases. 

Look at https://github.com/HPSoftware/ALMOctaneJavaRESTSDK#entity-generation for more information.  However you can do something like this:

final DefectEntityList defectEntityList = octane.entityList(DefectEntityList.class);
        final DefectEntityModel defect = defectEntityList.create().entities(Collections.singleton(
                new DefectEntityModel("defect", featureEntityModel, Phases.DefectPhase.DEFERRED)
        )).execute().iterator().next();
        defect.setSeverity(Lists.Severity.HIGH).setDescription("this has been updated");
        defectEntityList.update().entities(Collections.singleton(defect)).execute();

The allowed phases are typed enums so it makes it a lot easier. 

This works with other entities as well.

Hope this helps

Spencer

0 Likes
Cadet 1st Class
Cadet 1st Class

Thanks, Spencer for the previous reply but I tried updating the status using below code which is working when I run from the main method  but am getting below response whenever I try it on a server not getting a clue where I went wrong 

response: The request was retried 0 time(s), the exception could not be handled

my intention to write the method this way is so that I can use a single method to update phase for all entities 

**************************************** java code *************************************************************

public static void main(String[] args) {
HPOctaneAlmConnector connector = new HPOctaneAlmConnector();
System.out.println(connector.updateWorkItemStatus("autorabi.com", "2001", "defects,8001", "phase.defect.opened",));
}

String updateWorkItemStatus(String orgName, String projectKey, String workItemId, String status)  {
try {
String[] wrkItmID_entity = workItemId.split(",");
if(wrkItmID_entity!=null && wrkItmID_entity.length == 2) {
octaneBuilder.workSpace(Long.valueOf(projectKey.trim()));
octane = octaneBuilder.build();
entityList = octane.entityList(wrkItmID_entity[0].trim()+"");
statement = Query.statement("id", QueryMethod.EqualTo, Integer.valueOf(wrkItmID_entity[1].trim()));
FieldModel<EntityModel> phaseField =
new ReferenceFieldModel("phase",
new EntityModel(new HashSet<>(Arrays.asList(
new StringFieldModel("type", "phase"),
new StringFieldModel("id", status)
))));
final Set<FieldModel> entityFields = new HashSet<>(Arrays.asList(phaseField));
final EntityModel entityModel1 = new EntityModel(entityFields);
entityList.update().query(statement.build()).entities(new ArrayList<>(Collections.singletonList(entityModel1))).execute();
}
}catch(Exception e) {
return "work Item Updated was Unsuccessfully";
}
return "work Item Updated Successfully";

****************************************************************************************************************************

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.