predictionio-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Honders <dennishond...@gmail.com>
Subject Re: Eventserver: Can't convert JArray
Date Tue, 23 May 2017 14:11:49 GMT
Yes, missed that in the docs. Thanks.

2017-05-22 6:07 GMT+02:00 Chan Lee <chanlee514@gmail.com>:

> What api endpoint are you using? It should be /batch/events.json as in
> https://predictionio.incubator.apache.org/datacollection/eventmodel/#3.-
> batch-events-to-the-eventserver
>
>
> On Sun, May 21, 2017 at 12:02 PM, Dennis Honders <dennishonders@gmail.com>
> wrote:
>
>> For the following request to the eventserver (json array):
>>
>> [
>> {"event": "cart-transaction", "entityId": "1", "entityType": "user",
>> "targetEntityId": "12", "targetEntityType": "item"},
>> {"event": "cart-transaction", "entityId": "1", "entityType": "user",
>> "targetEntityId": "13", "targetEntityType": "item"},
>> {"event": "cart-transaction", "entityId": "1", "entityType": "user",
>> "targetEntityId": "14", "targetEntityType": "item"}
>> ]
>>
>> I receive the following error:
>>
>> {"message":"Can't convert JArray(List(JObject(List((event,JString(cart-transaction)),
>> (entityId,JString(1)), (entityType,JString(user)),
>> (targetEntityId,JString(12)), (targetEntityType,JString(item)))),
>> JObject(List((event,JString(c
>> art-transaction)), (entityId,JString(1)), (entityType,JString(user)),
>> (targetEntityId,JString(13)), (targetEntityType,JString(item)))),
>> JObject(List((event,JString(cart-transaction)), (entityId,JString(1)),
>> (entityType,JString(
>> user)), (targetEntityId,JString(14)), (targetEntityType,JString(item))))))
>> to class org.apache.predictionio.data.storage.Event"}
>>
>> The following data object succeeds (single json object):
>>
>> {"event": "$set", "entityType": "item", "entityId": "1", "properties":
>> {"category": ["1", "2", "3", "4", "5", "6", "7"], "manufacturer": 1,
>> "label": "test", "price": "$1-$2"}}
>>
>> I have a python script to import the data. I both use the same script to
>> import both. Only passing other value to the parameter.
>>
>> def make_request(data):
>>     data = json.dumps(data)
>>     print(data)
>>     headers = {'content-type': 'application/json'}
>>
>>     r = requests.post(url=API_ENDPOINT, data=data, headers=headers)
>>     print(r.text)
>>
>> What could be the problem?
>>
>
>

Mime
View raw message