Adding account fails with obscure exception( i.e. IncompleteArgumentException)

StackOverflow https://stackoverflow.com/questions/23643561

  •  22-07-2023
  •  | 
  •  

Question

I am trying to use the REST API to add accounts to my private zone implementation. I have been modifying SDK sample code, but my minor modification seems to result in failure and I'm not sure why. Note: obviously, I'm not including the actual username and password. Also, the site ID is for AMEX.

Here's the code (again, which is modified from example code):

public String addSiteAccount(String cobrandSessionToken,
  String userSessionToken) {
DefaultHttpClient httpclient = new DefaultHttpClient();
String url = HOST_URI + ADD_SITE_ACC;
try {
  HttpsURLConnection.setDefaultHostnameVerifier(new NullHostnameVerifier());

  PostMethod pm = new PostMethod(url);
  pm.addParameter(paramNameCobSessionToken, cobrandSessionToken);
  pm.addParameter(paramNameUserSessionToken, userSessionToken);

  String theUsername = "...whatever...";
  String thePassword = "...whatever...";

  pm.addParameter("credentialFields[0].name", "LOGIN");
  pm.addParameter("credentialFields[0].displayName", "Username");
  pm.addParameter("credentialFields[0].isEditable", "true");
  pm.addParameter("credentialFields[0].isOptional", "false");
  pm.addParameter("credentialFields[0].helpText", "22059");
  pm.addParameter("credentialFields[0].valuePattern", "null");
  pm.addParameter("credentialFields[0].defaultValue", "null");
  pm.addParameter("credentialFields[0].value", theUsername);
  pm.addParameter("credentialFields[0].validValues", theUsername);
  pm.addParameter("credentialFields[0].displayValidValues", "null");
  pm.addParameter("credentialFields[0].valueIdentifier", "LOGIN");
  pm.addParameter("credentialFields[0].valueMask", "LOGIN_FIELD");
  pm.addParameter("credentialFields[0].fieldType", "LOGIN");
  pm.addParameter("credentialFields[0].validationRules", "null");
  pm.addParameter("credentialFields[0].size", "20");
  pm.addParameter("credentialFields[0].maxlength", "40");
  pm.addParameter("credentialFields[0].userProfileMappingExpression",
      "null");
  pm.addParameter("credentialFields[0].fieldErrorCode", "1");
  pm.addParameter("credentialFields[0].fieldErrorMessage", "null");

  pm.addParameter("credentialFields[1].name", "PASSWORD");
  pm.addParameter("credentialFields[1].displayName", "Password");
  pm.addParameter("credentialFields[1].isEditable", "true");
  pm.addParameter("credentialFields[1].isOptional", "false");
  pm.addParameter("credentialFields[1].helpText", "AUS_Row_Name");
  pm.addParameter("credentialFields[1].valuePattern", "null");
  pm.addParameter("credentialFields[1].defaultValue", "null");
  pm.addParameter("credentialFields[1].value", thePassword);
  pm.addParameter("credentialFields[1].validValues", thePassword);
  pm.addParameter("credentialFields[1].displayValidValues", "null");
  pm.addParameter("credentialFields[1].valueIdentifier", "PASSWORD");
  pm.addParameter("credentialFields[1].valueMask", "LOGIN_FIELD");
  pm.addParameter("credentialFields[1].fieldType", "PASSWORD");
  pm.addParameter("credentialFields[1].validationRules", "null");
  pm.addParameter("credentialFields[1].size", "20");
  pm.addParameter("credentialFields[1].maxlength", "40");
  pm.addParameter("credentialFields[1].userProfileMappingExpression",
      "null");
  pm.addParameter("credentialFields[1].fieldErrorCode", "1");
  pm.addParameter("credentialFields[1].fieldErrorMessage", "null");
  pm.addParameter("credentialFields.objectInstanceType",
      "[Lcom.yodlee.common.FieldInfoSingle;");

  pm.addParameter("siteId", "12");
  // pm.addParameter("siteId.objectInstanceType", "long");

  HttpClient hc = new HttpClient();
  hc.executeMethod(pm);

  String source = pm.getResponseBodyAsString();

  System.out.println(pm.getResponseBodyAsString());

} catch (Exception e) {
  e.printStackTrace();
} finally {
  httpclient.getConnectionManager().shutdown();
}

return userSessionToken;

}

The result I get is:

{"errorOccurred":"true","exceptionType":"Exception Occurred","referenceCode":"_2ee6cfc1450c-42b8-86ec-7caef38f17bc"}

After failing here, I tried to simplify the code based on the minimum required parameters as mentioned here.

  pm.addParameter("siteId", "12");
  pm.addParameter("credentialFields.enclosedType",
      "com.yodlee.common.FieldInfoSingle");

  pm.addParameter("credentialFields[0].fieldType.typeName", "IF_LOGIN");
  pm.addParameter("credentialFields[0].name", "LOGIN1");
  pm.addParameter("credentialFields[0].size", "20");
  pm.addParameter("credentialFields[0].value", theUsername);
  pm.addParameter("credentialFields[0].valueIdentifier", "LOGIN");
  pm.addParameter("credentialFields[0].valueMask", "LOGIN_FIELD");
  pm.addParameter("credentialFields[0].isEditable", "true");
  pm.addParameter("credentialFields[0].displayName", "Username");

  pm.addParameter("credentialFields[1].fieldType.typeName", "IF_PASSWORD");
  pm.addParameter("credentialFields[1].name", "PASSWORD");
  pm.addParameter("credentialFields[1].size", "20");
  pm.addParameter("credentialFields[1].value", thePassword);
  pm.addParameter("credentialFields[1].valueIdentifier", "PASSWORD1");
  pm.addParameter("credentialFields[1].valueMask", "LOGIN_FIELD");
  pm.addParameter("credentialFields[1].isEditable", "true");

However, this fails with:

{"errorOccurred": "true", "exceptionType": "com.yodlee.core.IncompleteArgumentException", "referenceCode": "_0a549c3d-11f4-4c98-8e65-7f845fd83f54","message":"LOGIN"}

This also makes me wonder: do I need to make calls to searchSite() and getLoginForm() before issuing the code above? In our application, we have the site IDs and the login information, so we do not need to interact with a user per se. But I'm not sure if workflow is somehow being tracked on the backend, and we're violating it or something.

Any help would be appreciated. Incidentally, if there are any better examples for using REST to add accounts, it would be greatly appreciated. I have searched the developer portal, but it's a bit difficult to find a concise example. Thank you.

Was it helpful?

Solution

Yes, please we suggest you to use the field's value which you receive in response of getLoginForm API to provide the required input parameters in addSiteAccount1 API.

And to get this working please correct this parameter's value. credentialFields[0].name= "LOGIN1" instead of "LOGIN" Ideally that should work but in case you still get same error then please change below mentioned parameter's value as well.

"credentialFields[0].valueIdentifier", "LOGIN" to "LOGIN1"

This should help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top