Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

How to request API access programmatically using API Platforms RESTful API

公開日: Mar 2, 2024
解決策
When you are browsing for API's using the developer portal, usually you need to request access to receive a client ID and secret.
This can be done manually by pressing the request access button. But if you want to perform this activity programmatically, follow these steps:
  1. Log in to the API Platform API
  2. Obtain you organization ID
  3. Get you application ID or create a new application
  4. Get the target API ID
  5. Submit your access request
1. Logging into API Platform API
POST /accounts/login HTTP/1.1
Host: anypoint.mulesoft.com
Content-Type: application/json
 
{
    "username" : "USERNAME",
    "password" : "PASSWORD"
}
 
This call will return an authorization token that will be used on all subsequent requests on the Authorization header.
 
2. Obtain organization ID
GET /accounts/api/me HTTP/1.1
Host: anypoint.mulesoft.com
Authorization: Bearer AUTH-TOKEN
 
This will return several details about our account, particularly we are looking for our organization ID, we'll submit as a URI parameter in subsequent requests.
 
3.a Get application ID
GET /apiplatform/repository/v2/organizations/ORGANIZATION-ID/applications HTTP/1.1
Host: anypoint.mulesoft.com
Authorization: bearer AUTH-TOKEN
 
This will return our list of applications. We should look for the ID of the application we want to subscribe to the API.
 
3.b Create a new application
POST /apiplatform/repository/v2/organizations/ORGANIZATION-ID/applications HTTP/1.1
Host: anypoint.mulesoft.com
Authorization: bearer AUTH-TOKEN
Content-Type: application/json
 
{"name": "APP NAME", "description": "APP DESCRIPTION", "url": "APP URL", "redirectUri": ["OAUTH CALLBACK URL"]}
 
This will create a new app and return its details, the ID in particular.
Fields that won't be used on creation can be omitted.
 
4. List available APIs
GET /apiplatform/repository/v2/organizations/ORGANIZATION-ID/apis HTTP/1.1
Host: anypoint.mulesoft.com
Authorization: bearer AUTH-TOKEN
 
This will return a list of all available APIs. We shall get the API VERSION ID of the API we are requesting access to.
 
5. Request access
POST /apiplatform/repository/v2/organizations/ORGANIZATION-ID/applications/APPLICATION-ID/contracts HTTP/1.1
Host: anypoint.mulesoft.com
Authorization: bearer AUTH-TOKEN
Content-Type: application/json
 
{"apiVersionId":API-VERSION-ID,"applicationId":APP-ID,"partyId":"","partyName":"","requestedTierId":null,"acceptedTerms":false}
 
With this last step we have fully requested access to the API.
Complete request fields appropriately when submitting the request.
 
For more details on API Platform API please refer to the Online specs.
 
ナレッジ記事番号

001118739

 
読み込み中
Salesforce Help | Article