predictionio: why can I make post requests with curl but not python?

339 views Asked by At

I am trying to import data into predictionio. I can send each event individually with curl fine:

curl -i -X POST http://localhost:7070/events.json?accessKey=285285285 \
-H "Content-Type: application/json" \
-d '{
  "event" : "buy",
  "entityType" : "user",
  "entityId" : "u1",
  "targetEntityType" : "item",
  "targetEntityId" : "i2",
  "eventTime" : "2014-11-10T12:34:56.123-08:00"
}'
HTTP/1.1 201 Created
Server: spray-can/1.3.3
Date: Fri, 23 Dec 2016 00:02:32 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 46

{"eventId":"48a00669b43f4655b9e64762721b859d"}

However when I try to automate this using Python I get an error. Here is the Python script:

import predictionio
client = predictionio.EventClient(
    access_key='285285285',
    url='http://localhost:7070',
    threads=5,
    qsize=500)

client.create_event(
                event="rate",
                entity_type="user",
                entity_id="Bob",
                target_entity_type="item",
                target_entity_id="Fred",
                properties= { "rating" : 5.0 }
            )  


Gives the following error..

predictionio.NotCreatedError: Exception happened: [Errno 10061] No connection could be made because the target machine a
ctively refused it for request POST /events.json?accessKey=285285285 {'event': 'rate', 'eventTime': '2016-12-22T23:13:24
.210+0000', 'entityType': 'user', 'targetEntityId': 'Fred', 'properties': {'rating': 5.0}, 'entityId': 'Bob', 'targetEnt
ityType': 'item'} /events.json?accessKey=285285285?event=rate&eventTime=2016-12-22T23%3A13%3A24.210%2B0000&entityType=us
er&targetEntityId=Fred&properties=%7B%27rating%27%3A+5.0%7D&entityId=Bob&targetEntityType=item

What does this error imply and what can I possibly do to rectify it. Thanks in advance

0

There are 0 answers