predictionio:为什么我可以用curl而不是python发出post请求?

2024-09-30 12:19:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将数据导入predictionio。我可以用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"}

但是,当我试图使用Python实现自动化时,我得到了一个错误。下面是Python脚本:

^{pr2}$


给出以下错误。

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

这个错误意味着什么?我能做些什么来纠正它。提前谢谢


Tags: eventjsontype错误contentcurleventsitem

热门问题