我读过一些文档,其中说要传递Hubspot日期字段的值,您应该将日期格式化为午夜UTC。然而,我在Python中没有这样做的运气。我想我只是错过了能得到正确结果的魔法Python咒语。以下是我所拥有的:
from pytz import timezone, utc
from hubspot.crm.contacts import SimplePublicObject,
created_dt = # datetime from sqlalchemy query
utcdt = utc.localize(
datetime(
year=created_dt.year,
month=created_dt.month,
day=created_dt.day
)
)
ts = int(utcdt.timestamp())
props = SimplePublicObjectInput({"last_booking": str(ts)})
return client.crm.companies.basic_api.update(
hs_id, simple_public_object_input=props
)
这将返回以下错误:
{"status":"error",
"message":"Property values were not valid: [{\"isValid\":false,\"message\":\"1570233600 is at 4:10:33.600 UTC, not midnight!\"...
}
使用Hubspot支持的“sanetime”模块:https://github.com/HubSpot/sanetime
然后,要获得日期:
或者,如果不需要依赖项:
你有没有尝试在约会时间通话中增加小时和分钟
啊,答案就在那里。Python
timestamp
以秒为单位返回时间,HubSpot需要微秒。我只需要乘以1000:现在一切看起来都很好
相关问题 更多 >
编程相关推荐