Vittore Gravano
Vittore Gravano

Reputation: 766

AWS Personalize — eventType must be an associative array

Documentation says that eventType must be a string https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-personalize-events-2018-03-22.html#putevents

So I did:

/* @var PersonalizeEventsClient $client */
$client->putEvents([
    'trackingId' => $trackingId,
    'sessionId' => $uniqueId,
    'userId' => '2',
    'eventList' => [
        'itemId' => '1',
        'eventType' => 'click',
        'sentAt' => (string) time(),
    ],
]);

But I receive next validation errors:

[eventList][eventType] must be an associative array. Found string(5) "click"
[eventList][sentAt] must be an associative array. Found string(10) "1611590718"

Any ideas how it should work? I've tried json_encode, ['eventType' => ['key' => 'click']], but it doesn't work.

Upvotes: 0

Views: 571

Answers (1)

Vittore Gravano
Vittore Gravano

Reputation: 766

Well, eventList must be an array of arrays. Problem solved:

/* @var PersonalizeEventsClient $client */
$client->putEvents([
    'trackingId' => $trackingId,
    'sessionId' => $uniqueId,
    'userId' => '2',
    'eventList' => [
        [
            'itemId' => '1',
            'eventType' => 'click',
            'sentAt' => (string) time(),
        ],
    ],
]);

Upvotes: 1

Related Questions