REST メッセージに OAuth プリセットがない場合、OAuth プロファイルの設定が機能しない。Issue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } 認証プロファイルを OAuth 2.0 プロファイルに設定するために RESTMessageV2 メソッドが使用されている場合は、REST メッセージ自体で認証タイプを「OAuth 2.0」に設定した場合にのみ機能します。空白のままにすると(たとえば、基本とOAuthのどちらを使用するかを実行時に決定する場合)、メソッド「setAuthenticationProfile」はOAuthプロファイルを設定しません。 再現手順:1.「My REST Message」という名前の新しい REST メッセージを作成します。2.GET などを使用して REST メッセージ関数を追加します。3.REST メッセージまたはその機能の認証タイプフィールドに値を設定しないようにしてください。4.認証トークンを取得するために動作しているサンプル Oauth プロファイルを作成します。5.以下のスクリプトを実行します。 sm = new sn_ws.RESTMessageV2("My REST Message", "get");sm.setAuthenticationProfile('oauth2', 'addSysIDOfNewlyCreatedProfileInStep4'); //set auth profile to an OAuth 2.0 profile record.sm.setLogLevel('all');var response = sm.execute() 6.送信 http ログを確認し、プロファイルが適用されていないため、メッセージとともに認証トークンが送信されていないことを確認します。7.REST メッセージに戻り、認証タイプを「OAuth 2.0」に設定し、任意の OAuth プロファイルを使用しますが、手順 4 のものは使用しないでください。8.手順 5 と 6 を繰り返し、手順 4 のプロファイルのトークンが実行に使用されていることに注意してください。 Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Cause<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } RESTMessageV2 を使用するときにスクリプト可能レイヤーで指定されたものはすべて、REST メッセージレコードの設定内容を上書きします。REST メッセージレコードに明示的な認証タイプ + プロファイルが指定されていない場合は、実行時に指定されたものが使用されます。ただし、トークンを生成するにはリクエスタプロファイルが必要なため、REST メッセージで認証プロファイルを明示的に指定しない場合は、"setRequestorProfile" を明示的に呼び出す必要があります。そうしないと、リクエスタプロファイルが null になり、トークンが生成されません。 Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } トップレベルの REST メッセージレコードとそれに含まれる HTTP メソッドレコードの両方を参照する RESTMessageV2 を使用した OAuth の順列を次に示します。 1.REST メッセージに特定の OAuth プロファイルが含まれていない場合は、「setAuthenticationProfile」と「setRequestorProfile」の両方を明示的に呼び出す必要があります。2.REST メッセージには、特定の OAuth プロファイルが含まれています。REST メッセージレコードで指定されたプロファイルを上書きする場合は、「setAuthenticationProfile」を呼び出すことができます。この場合、「setRequestorProfile」はRESTメッセージに関連付けられているため、必要ありません。3.REST メッセージには、特定の OAuth プロファイルが含まれています。REST メッセージで指定された OAuth プロファイルを使用する必要がある場合は、自動的に処理されるため、「setAuthenticationProfile」および「setRequestorProfile」メソッドを呼び出す必要はありません。 Related Links<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } https://developer.servicenow.com/dev.do#!/reference/api/paris/server/sn_ws-namespace/c_RESTMessageV2API