2

我的任务很简单,我所要做的就是在销售人员的领导部分创建记录。我创建了一个免费帐户,但我无法弄清楚下面的 api 中的https://yourinstance.saleforce.com是什么:

https://yourinstance.salesforce.com/services/data/v39.0/sobjects/Lead

正文 JSON:

{
    "body": {
    "Salutation": "Mr.",
    "FirstName": "H",
    "LastName": "Sam",
    "Company": "Samosto"
    }
}

标题:

Authorization: Bearer 00D0o0000015jPn!ARgAQPiIGhuYGUG_c0HDKNR0hxTX9zS82Fv1lIuqn4rapFJHPR422gLyi10rF8Auukb._hj9pj532DP7IajQV36lyKpUNEXdxvL

Content-Type: application/json

Sforce-Auto-Assign: TRUE

任何帮助将不胜感激!

4

2 回答 2

2

这是您要登录的组织的 URL。由于大多数组织在指南或示例中都使用自己的域名,因此您会看到“ https://yourinstance.saleforce.com ”被使用。

您可以在登录 Salesforce 时简单地从 URL 中获取它,或者转到设置 -> 快速搜索“我的域”,您将看到域名。从这里检查它是一件好事,因为通用 URL 也可以作为登录选项被阻止。

于 2019-01-23T11:34:21.137 回答
0

fwiw 我认为 API 已更改为Account。这对我有用

// to run:
//     node create_new_account.js --config ./config_na150_scan_email_app.json
//
// links:
// https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm



const axios = require("axios");
const qs = require("qs");
const yargs = require("yargs");

const argv = yargs
    .command('create_account', 'test creating salesforce leads', {
        config: {
            description: 'config',
            alias: 'c',
            type: 'string',
        }
    })
    .help()
    .alias('help', 'h')
    .argv;


let { salesforce, scanResultsURL } = require(argv.config);

const auth_data = qs.stringify({"username": salesforce.username,
                "password": salesforce.password + salesforce.security_token,
                "grant_type": "password",
                "client_id": salesforce.consumer_key,
                "client_secret": salesforce.customer_secret,
                "redirect_uri": salesforce.redirect_uri});

console.log("auth data", auth_data)

const auth_config = {
    method: "post",
    url: salesforce.oauth2_uri,
    data: auth_data,
    headers: {"Content-Type": "application/x-www-form-urlencoded"}
}


const action_url = "https://na<TBD>.salesforce.com/services/data/v51.0/sobjects/Account"

console.log('action url', action_url)

data = {
    "Name" : "test Salesforce account API"
}

async function createAccout() {

    // "get" token
    axios(auth_config).then(function (response) {

    auth_header = {"Authorization": "Bearer " + response["data"]["access_token"]}

    action_config = {
        method: "post",
        url: action_url,
        headers: auth_header,
        data: data
    }


    // use valid token to send email
    axios(action_config).then(function (response) {

        console.log("action response", response["data"]); // TODO rm

    }).catch(function (error) {
        console.log("authenticated passed, action failed")

        console.log("action error", error); // TODO something
    })

    }).catch(function (error) {
    console.log("action token error", error); // TODO something
    })

}
于 2021-04-20T21:45:58.440 回答