2017-01-29 5 views
0

Die Shopify API-Referenz sagt:Shopify Python API anfordern ISO 8601 Fomat

updated_at_min
Produkte anzeigen zuletzt nach Datum (Format aktualisiert: 2014-04-25T16: 15: 47-04: 00)

Wenn ich ein Datetime-Objekt, wenn ein API-Aufruf zu machen, muß ich die Datetime zu einem String von ISO 8601, bevor die Anforderung konvertieren?

d. Muss ich das tun?

min_date = timezone.now() 
shopify.Product.count(created_at_min = str(min_data.isoformat())) 

Meine Anfrage wie diese dann aussehen:

https://[store-url].myshopify.com/admin/products/count.json?updated_at_min=2017-01-29T14%3A43%3A27-05%3A00 

dieses Versus (wenn ich übergeben Sie die unformatiert Datetime-Objekt in):

https://[store-url].myshopify.com/admin/products/count.json?updated_at_min=2016-12-10+14%3A43%3A27-05%3A00 

(Wenn ja , warum funktioniert die Shopify Python-API nicht automatisch mit dieser Konvertierung, scheint irgendwie albern zu sein?)

+0

Ich habe das nicht benutzt, aber wenn es so ist, kann es sinnvoll sein, ein Problem mit der Shopify Python-Bibliothek zu öffnen, wenn Sie denken, dass es schon damit umgehen sollte. –

+0

Danke, ich habe es gerade erstellt: https://github.com/Shopify/shopify_python_api/issues/175 – cj1689262

Antwort

0

(Von einer Antwort auf mein Problem auf dem Shopify Python Repo): Die Shopify API akzeptiert tatsächlich mehrere Datumsformate, aber es ist immer am sichersten, das Format zu verwenden, das in der API-Dokumentation (ISO 8601) dokumentiert ist das wird garantiert auch in Zukunft funktionieren.

Das aktuelle Shopify-Python-Modul verarbeitet derzeit keine Datumsformatierung, da der Großteil der Funktionalität der Bibliothek für das Wrapping von HTTP-Anfragen mit pyactiveresource dient - es ist größtenteils ein Port von https://github.com/shopify/shopify_api und wurde dafür nicht erweitert.