Forum

This content is now out of date.

Visit Our Community

Importing reports via web service

Hi,

I'm trying to import using web services and it's always creating a new report during the import. I'm sure there must be an option to set to replace existing reports rather to add a new using setImportOptions().

Please mention what should be the option to replace existing items during import.

I'm using below code to import.

AdministrationServiceRequest rsr = new AdministrationServiceRequest();
AdministrationServiceResponse rs = null;
AdministrationServiceService ts = new AdministrationServiceServiceLocator(this.host, this.port, "/services/AdministrationService", false);
AdministrationServiceSoapBindingStub rssbs;
try {
rssbs = (AdministrationServiceSoapBindingStub) ts.getAdministrationService();

rsr.setLoginId(this.username);
rsr.setPassword(this.password);
// This is the primary organisation
rsr.setOrgId(new Integer(1));
rsr.setFunction("IMPORTCONTENT");
rsr.setParameters( new String[] { Base64.encodeBytes(data) } );
rs = rssbs.remoteAdministrationCall(rsr);
} catch (RemoteException e) {
e.printStackTrace();
}


Thanks
Prishan
Hi Prishan,

Thanks for sending in the question. Sorry to hear you are running into troubles with IMPORTCONTENT.

Unless you specify, IMPORTCONTENT will add a new report rather than replace a previously existing report. You can change this by using the following syntax:

cat_io.setOptionKey("OPTION");
cat_io.setOptionValue("REPLACE");

cat_io.setOptionKey("EXISTING");
cat_io.setOptionValue("28781"); //this is your report ID

[code]
ArrayList importOptions = new ArrayList();

ImportOption cat_io = null;

cat_io = new ImportOption();
cat_io.setItemIndex(0);
cat_io.setOptionKey("OPTION");
cat_io.setOptionValue("REPLACE");
importOptions.add(cat_io);

cat_io = new ImportOption();
cat_io.setItemIndex(0);
cat_io.setOptionKey("EXISTING");
cat_io.setOptionValue("28781");
importOptions.add(cat_io);
[/code]

This information can be found on our wiki:

Web Services - Administration Service

Scroll all the way down beneath Object Definitions, and click on the ImportOption drop down for a list of all the available optionkeys/optionvalues.

Also, I've gone ahead and attached an example of the IMPORTCONTENT web service for you to take a look at.

Could you let us know if this is helpful?

Let us know if you have any questions or concerns.

Kind Regards,

Dustin