我正在嘗試將Salesforce Mobile SDK用於本機Android。 要求:Salesforce MobileSDK:該組織未啓用Rest API
- 允許與Salesforce帳戶的用戶登錄
- 取他/她的聯繫人列表
- 獲取特定的聯繫方式
請讓我知道,如果這些不屬於Mobile SDK的一部分。
我也跟着https://github.com/forcedotcom/SalesforceMobileSDK-Android:
- 將其克隆
- 安裝NPM和安裝所需的子模塊
- 創建使用本地forcedroid
- 一個新的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"
}
編輯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();
}
});
}
});
}
編輯2:一些更多的發現:
我認爲它有使用我的帳戶/連接的應用程序設置。因爲 當我signedup使用https://developer.salesforce.com/signup和使用
username
它工作正常。這裏再次如果我使用username
s使用相同的順便說一句我目前正在使用salesforce的試用版。
我想你已經把JsonArrayRequest提供給了API。 –
@Bansal請求代碼由SDK生成,因此它是標準的。 – Housefly
也許嘗試使用Salesforce的Android本機樣例應用程序之一https://github.com/forcedotcom/SalesforceMobileSDK-Android/tree/master/native/NativeSampleApps/RestExplorer –