Hou*_*fly 7 android salesforce
我正在尝试将Salesforce Mobile SDK用于原生Android.需求:
- 允许任何拥有Salesforce帐户的用户登录
- 获取他/她的联系人列表
- 获取特定联系人详细信息
如果这些不属于Mobile SDK,请告知我们.
我关注https://github.com/forcedotcom/SalesforceMobileSDK-Android:
- 克隆它
- 安装NPM并安装所需的子模块
- 使用原生的forceroid创建了一个新的Android应用程序
bootconfig.xml使用我连接的应用程序的值更改了值.
它记录正常,但当我尝试获取联系人时,它说:
未为此组织启用Rest API
登录响应似乎没问题.客户端对象json凭据:
{
"clientId": "*******",
"loginUrl": "https://login.salesforce.com",
"identityUrl": "https://login.salesforce.com/id/99VVHJHGF5688/00548000003yOKeAAM",
"instanceUrl": "https://ap2.salesforce.com",
"userId": "**********",
"orgId": "*********",
"communityUrl": null,
"refreshToken": "*************",
"accessToken": "************",
"communityId": null,
"userAgent": "SalesforceMobileSDK/4.3.0 android mobile/7.0 (Nexus 6P) SFTest/1.0 Native uid_32aea9bdde1b8b7e"
}
Run Code Online (Sandbox Code Playgroud)
编辑1:获取联系人列表的代码:
public void onFetchContactsClick(View v) throws UnsupportedEncodingException {
sendRequest("SELECT Name FROM Contact");
}
private void sendRequest(String soql) throws UnsupportedEncodingException {
RestRequest restRequest = RestRequest.getRequestForQuery(ApiVersionStrings.getVersionNumber(this), soql);
client.sendAsync(restRequest, new AsyncRequestCallback() {
@Override
public void onSuccess(RestRequest request, final RestResponse result) {
result.consumeQuietly(); // consume before going back to main thread
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
listAdapter.clear();
JSONArray records = result.asJSONObject().getJSONArray("records");
for (int i = 0; i < records.length(); i++) {
listAdapter.add(records.getJSONObject(i).getString("Name"));
}
} catch (Exception e) {
onError(e);
}
}
});
}
@Override
public void onError(final Exception exception) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this,
MainActivity.this.getString(SalesforceSDKManager.getInstance().getSalesforceR().stringGenericError(), exception.toString()),
Toast.LENGTH_LONG).show();
}
});
}
});
}
Run Code Online (Sandbox Code Playgroud)
编辑2:更多的发现:
我认为这与我的帐户/已连接的应用设置有关.因为当我使用https://developer.salesforce.com/signup进行 signedup 并使用
username它时工作正常.在这里,如果我使用它username使用相同BTW我目前正在使用salesforce的试用版.
| 归档时间: |
|
| 查看次数: |
194 次 |
| 最近记录: |