POST request to the prediction REST api

51 views
Skip to first unread message

Meniar Laatiri

unread,
May 17, 2021, 4:53:20 PM5/17/21
to cloud-recommendations-users
Hello,

According to the documentation, to get a recommendation you need to make a POST request to the predict REST method and provide the appropriate request body. (link of the documentation page: https://cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.placements/predict).
In the request body, the UserEvent Object is required. I want to know if the the field "eventType" is required or not? and if yes, why this field is required? What's the point?
Also, I want to know if all the fields are required or it depends on the eventType ? 

Please help me better understand!

Example from the doc:
 curl -X POST \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    --data  '{
          "filter": "FILTER_STRING",
          "validateOnly": false,
          "userEvent": {
              "eventType": "detail-page-view",
              "visitorId": "VISITOR_ID",
              "userInfo": {
                  "userId": "USER_ID",
                  "ipAddress": "IP_ADDRESS",
                  "userAgent": "USER_AGENT"
              },
              "experimentIds": "EXPERIMENT_GROUP",
              "productDetails": [{
                  "product": {
                    "id": "PRODUCT_ID"
                 }
              }]
          }' \
https://retail.googleapis.com/v2/projects/[PROJECT_ID]/locations/global/catalogs/default_catalog/placements/PLACEMENT_ID:predict

Best Regards,
Meniar


Reply all
Reply to author
Forward
0 new messages