添加帐户失败并出现模糊异常(即IncompleteArgumentException)

时间:2014-05-14 00:02:18

标签: yodlee

我正在尝试使用REST API将帐户添加到我的私有区域实现中。我一直在修改SDK示例代码,但我的小修改似乎导致失败,我不知道为什么。注意:显然,我不包括实际的用户名和密码。此外,站点ID适用于AMEX。

这里是代码(再次,从示例代码修改):

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;

}

我得到的结果是:

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

在此失败后,我尝试根据提到的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");

然而,这失败了:

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

这也让我想知道:在发出上面的代码之前,我是否需要来调用searchSite()和getLoginForm()?在我们的应用程序中,我们有站点ID和登录信息,因此我们不需要与用户本身进行交互。但我不确定工作流是否会以某种方式在后端进行跟踪,而且我们会违反它或其他内容。

任何帮助将不胜感激。顺便说一下,如果有更好的示例使用REST来添加帐户,我们将不胜感激。我搜索过开发人员门户网站,但找到一个简洁的例子有点困难。谢谢。

1 个答案:

答案 0 :(得分:0)

是的,我们建议您使用您在 getLoginForm API的响应中收到的字段值,以便在 addSiteAccount1 API中提供所需的输入参数。

要使其正常工作,请更正此参数的值。 credentialFields[0].name= "LOGIN1"代替"LOGIN" 理想情况下应该可以工作但是如果你仍然得到相同的错误,那么请改变下面提到的参数的值。

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

这应该有所帮助。