gpt4 book ai didi

android - Salesforce MobileSDK : The Rest API is not enabled for this Organization

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:10:53 25 4
gpt4 key购买 nike

我正在尝试使用适用于 native Android 的 Salesforce Mobile SDK。要求:

  1. Allow any user with Salesforce account to login
  2. Fetch his/her contacts list
  3. Fetch particular contact details

如果这些不是移动 SDK 的一部分,请告诉我。

我关注了https://github.com/forcedotcom/SalesforceMobileSDK-Android :

  1. Cloned it
  2. Installed NPM and installed the required submodules
  3. Created a new Android application using native forcedroid
  4. Changed the bootconfig.xml values with the values of my connected app.

它登录正常,但是当我尝试获取联系人时,它说:

The Rest API is not enabled for this Organization

enter image description here

登录响应似乎没问题。客户端对象 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: 更多发现:

I think it has to do with my account/connected app settings. Because when I signedup using https://developer.salesforce.com/signup and used the username it works fine. Here again if I used the email instead it shows the same error of API not enabled. I created multiple usernames using the same email and the signup form, they all work fine, but not the email.

BTW I am currently using a trial version of salesforce.

最佳答案

常规试用帐户适用于专业版,不包括 API 访问权限,这是您遇到的错误。您需要使用具有 API 访问权限的帐户,例如免费开发者版帐户或企业版帐户。

关于android - Salesforce MobileSDK : The Rest API is not enabled for this Organization,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39829033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com