You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@predictionio.apache.org by Dennis Honders <de...@gmail.com> on 2017/05/21 19:02:50 UTC

Eventserver: Can't convert JArray

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?

Re: Eventserver: Can't convert JArray

Posted by Dennis Honders <de...@gmail.com>.
Yes, missed that in the docs. Thanks.

2017-05-22 6:07 GMT+02:00 Chan Lee <ch...@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 <de...@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?
>>
>
>

Re: Eventserver: Can't convert JArray

Posted by Chan Lee <ch...@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 <de...@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?
>