0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

指定ログイン情報にて自分組織の外部クライアントアプリケーションへの接続エラーシューティング

0
Last updated at Posted at 2026-10-16
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 トークンを取得できません。

image.png

##エラー原因:
トークンエンドポイント URL
誤:https://mydomain--dev01.sandbox.my.force.com/services/oauth2/token
正:https://mydomain--dev01.sandbox.my.salesforce.com/services/oauth2/token

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?