public with sharing class ContentVersionRenameCallout {
@future(callout=true)
public static void renameViaSelfOrgApi(String contentVersionId) {
Map<String, String> payload = new Map<String, String>{
'contentVersionId' => contentVersionId
};
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:SalesforceSelf/services/apexrest/ContentVersionRename');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody(JSON.serialize(payload));
req.setTimeout(60000);
Http http = new Http();
HttpResponse res = http.send(req);
if (res.getStatusCode() != 200) {
// 必要に応じてログ出力や例外化
System.debug('Callout failed: ' + res.getStatusCode() + ' ' + res.getBody());
} else {
System.debug('Callout success: ' + res.getBody());
}
}
}
エラー
19:13:41:072 CALLOUT_REQUEST [33]|System.HttpRequest[Endpoint=callout:SalesforceSelf/services/apexrest/ContentVersionRename, Method=POST]
NAMED_CREDENTIAL_RESPONSE NamedCallout[Named Credential Id=null, Named Credential Name=null, Status Code=0, Content-Type=null, Response Size bytes=0, Overall Callout Time ms=0, Connect Time ms=0, Interceptor Time ms=0
19:13:41:401 EXCEPTION_THROWN [33]|System.CalloutException: OAuth トークンを取得できません。
##エラー原因:
トークンエンドポイント URL
誤:https://mydomain--dev01.sandbox.my.force.com/services/oauth2/token
正:https://mydomain--dev01.sandbox.my.salesforce.com/services/oauth2/token
