---
title: "ウェブ体験のためのAPIリクエストを作成する"
slug: "compose-the-api-request-for-a-web-experience"
abstract: "カスタムデータを返すためのAPIリクエストの構成方法の詳細を提供します。"
---
# ウェブ体験のためのAPIリクエストを作成する

APIリクエストを作成する際、組織のウェブサイトがコンテンツを正しく表示するために必要とするパラメータを入力しなければなりません。 [ウェブ体験応答の動的データをAPIリクエストにコピー&ペースト](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/compose-the-api-request-for-a-web-experiment/use-dynamic-experiment-data-in-the-api-request.html "Use dynamic experiment data in the API request") することができます。これは、依存するウェブサイトから要求された"uri"、"region"、"pointOfSale"などのAPIリクエストのパラメータを使いたい場合は必須です。

また、[意思決定モデルによって返されたコンテンツも](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/compose-the-api-request-for-a-web-experiment/use-dynamic-decision-model-data-in-the-api-request.html "Use dynamic decision model data in the API request")APIリクエストに含めることができます。

これを行うには、バリアントが動的データを含めるように設定し、バリアントが実行された際にサーバーが動的データを要求し、組織のウェブサイトに渡すようにする必要があります。

ウェブ体験のためのAPIリクエストを作成するには:

1.  コードエディターで**API**タブをクリックします。
    
2.  FreeMarkerを使ってAPIリクエストを作成します。
    
    > !ヒント必要に応じて [、ゲストデータモデル](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiences/introduction-to-web-experiences-in-sitecore-personalize/use-dynamic-guest-data-in-the-api-request-for-a-web-experiment.html "Use dynamic guest data in the API request for a web experiment") や [意思決定モデルの応答](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiences/introduction-to-web-experiences-in-sitecore-personalize/use-dynamic-decision-model-data-in-the-api-request.html "Use dynamic decision model data in the API request")から動的データをコピー&ペーストできます。
    
3.  その後、該当する[HTML](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-html-in-a-web-experiment.html "Use HTML in a web experiment")、[CSS](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-css-in-a-web-experiment.html "Use CSS in a web experiment")、[またはJavaScript](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-javascript-in-a-web-experiment.html "Use JavaScript in a web experiment")エディターに再度このデータを貼り付けて参照しなければなりません。
    
4.  **「保存**」をクリックします。
    
5.  コードエディタを閉じるには ![back.png](https://doc.sitecore.com/api/markdown-image/personalize/ja/users/sitecore-personalize/images/back.png) をクリックしてください。
    

> !注箱出しのウェブテンプレートを使う場合、またはそのテンプレートからJavaScriptをコピーした場合は、contextオブジェクト内でAPI応答の属性を参照しなければなりません。例えば、CSSにAPI応答のimageURLを含めるには、次のように参照してください:
> 
> background-image: URL("{{context.imageURL}}")