ここで使うAccount IDとは
事前準備
接続アプリケーションを作成して
アクセストークンなどのデータをスクリプトのプロパティに保存しておく
手順は以下のブログに書きました。
SalesforceでAPIを使うために接続アプリケーションを作成したい
Salesforceで接続アプリケーションを作成したい(Lightningの方で)
コード.gsfunction getData() {
var options = {
"method" : "GET",
"headers" : {
"Authorization": "Bearer " + getProp("access_token")
}
}
var url = getProp("instance_url") + "/services/data/v47.0/sobjects/Account/0012w000004AAugAAG";
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
function getProp(key) {
return PropertiesService.getScriptProperties().getProperty(key);
}
|
getData()を実行すると、以下のような結果が返ってきました。
実行結果{
"attributes": {
"type": "Account",
"url": "/services/data/v47.0/sobjects/Account/0012w000004AAugAAG"
},
"Id": "0012w000004AAugAAG",
"IsDeleted": false,
"MasterRecordId": null,
"Name": "(サンプル)グローバル鋼機株式会社",
"Type": "顧客",
"ParentId": null,
"BillingStreet": "東区下田町 0-0-4",
"BillingCity": "堺市",
"BillingState": "大阪府",
"BillingPostalCode": "590-0000",
"BillingCountry": "JP",
"BillingLatitude": null,
"BillingLongitude": null,
"BillingGeocodeAccuracy": null,
"BillingAddress": {
"city": "堺市",
"country": "JP",
"geocodeAccuracy": null,
"latitude": null,
"longitude": null,
"postalCode": "590-0000",
"state": "大阪府",
"street": "東区下田町 0-0-4"
},
"ShippingStreet": "東区下田町 0-0-4",
"ShippingCity": "堺市",
"ShippingState": "大阪府",
"ShippingPostalCode": "590-0000",
"ShippingCountry": "JP",
"ShippingLatitude": null,
"ShippingLongitude": null,
"ShippingGeocodeAccuracy": null,
"ShippingAddress": {
"city": "堺市",
"country": "JP",
"geocodeAccuracy": null,
"latitude": null,
"longitude": null,
"postalCode": "590-0000",
"state": "大阪府",
"street": "東区下田町 0-0-4"
},
"Phone": "(06) 6666-6000",
"Fax": null,
"AccountNumber": null,
"Website": null,
"PhotoUrl": "/services/images/photo/0012w000004AAugAAG",
"Sic": null,
"Industry": "22 鉄鋼業",
"AnnualRevenue": null,
"NumberOfEmployees": 14668,
"Ownership": null,
"TickerSymbol": null,
"Description": "グローバル鋼機株式会社は鉄鋼業界の世界的リーダーです。高い技術で多くの実績があり、グループ企業のネットワークは世界最大です。魅力的なコンテンツやデザインに画期的なインタラクティブ技術を組み合わせた鉄鋼用機器も販売し、何百万ものユーザー企業が存在します。FORBES 500にランクされています。",
"Rating": null,
"Site": null,
"OwnerId": "0052w000001oTfEAAU",
"CreatedDate": "2020-01-16T04:17:22.000+0000",
"CreatedById": "0052w000001oTfEAAU",
"LastModifiedDate": "2020-01-16T04:17:22.000+0000",
"LastModifiedById": "0052w000001oTfEAAU",
"SystemModstamp": "2020-01-16T04:17:22.000+0000",
"LastActivityDate": "2018-07-26",
"LastViewedDate": "2020-02-03T00:11:26.000+0000",
"LastReferencedDate": "2020-02-03T00:11:26.000+0000",
"Jigsaw": null,
"JigsawCompanyId": null,
"AccountSource": null,
"SicDesc": null
}
|
関連記事
SalesforceでAPIを使うために接続アプリケーションを作成したい
Salesforceで接続アプリケーションを作成したい(Lightningの方で)
参考
サンプルコードを実行する
https://developer.salesforce.com/docs/atlas.ja-jp.222.0.api_rest.meta/api_rest/quickstart_code.htm
