2016-07-14 7 views
0

Ich entwickle eine VB.NET Anwendung um mit unserem neuen Shopify Store zu interagieren. Ich bin dabei, die Produkterweiterungen/-aktualisierungen/-entfernungen basierend auf Daten in unserer Oracle-Datenbank zu automatisieren.Produkt hinzufügen Variante - 404 Fehler

Grundsätzlich erstellt die Anwendung einen neuen Shopify-Teil für ein Muster und erstellt dann Produktvarianten für jeden SKU in diesem Muster. Dies geschieht durch POSTing und PUTing Anfragen mit der HttpWebRequest Klasse. Das funktionierte gestern Nachmittag großartig, heute scheitert es aus irgendeinem Grund an der Erstellung/Aktualisierung der Produktvariante mit einem 404 - Not Found Fehlercode.

Das Produkt hinzufügen Anfrage JSON ist unten. Dies funktioniert perfekt, es erstellt den Teil auf Shopify, den ich dann über das Admin-Panel sehen kann. Dies wird POSTed an die URL „https://key:[email protected]/admin/products.json“ (wo Schlüssel und das Kennwort mit unserer Anmeldeinformation ersetzt werden)

{ 
    "product": { 
     "id": 0, 
     "body_html": "A classic combination of embroidery and cut work form the flowing border, creating your own seaside retreat. ", 
     "title": "Seabreeze Sand", 
     "vendor": "SKL", 
     "product_type": "", 
     "published_scope": "global", 
     "tags": "J71227", 
     "variants": null, 
     "options": null, 
     "images": [{ 
      "id": 0, 
      "product_id": 0, 
      "position": 1, 
      "src": "http:\/\/i320.photobucket.com\/albums\/nn353\/fkhphoto\/J71227main.jpg", 
      "variant_ids": null 
     }], 
     "image": null 
    } 
} 

Dies ist die JSON-Antwort, die ich nach diesem Aufruf bin empfangen, und ich kann auch der Teil hinzugefügt in denen sieht Shopify Admin-Panel:

{ 
    "product": { 
     "id": 7874734983, 
     "title": "Seabreeze Sand", 
     "body_html": "A classic combination of embroidery and cut work form the flowing border, creating your own seaside retreat. ", 
     "vendor": "SKL", 
     "product_type": "", 
     "created_at": "2016-07-14T10:43:56-04:00", 
     "handle": "seabreeze-sand", 
     "updated_at": "2016-07-14T10:43:56-04:00", 
     "published_at": "2016-07-14T10:43:56-04:00", 
     "template_suffix": null, 
     "published_scope": "global", 
     "tags": "J71227", 
     "variants": [{ 
      "id": 24925005383, 
      "product_id": 7874734983, 
      "title": "Default Title", 
      "price": "0.00", 
      "sku": "", 
      "position": 1, 
      "grams": 0, 
      "inventory_policy": "deny", 
      "compare_at_price": null, 
      "fulfillment_service": "manual", 
      "inventory_management": null, 
      "option1": "Default Title", 
      "option2": null, 
      "option3": null, 
      "created_at": "2016-07-14T10:43:56-04:00", 
      "updated_at": "2016-07-14T10:43:56-04:00", 
      "taxable": true, 
      "barcode": null, 
      "image_id": null, 
      "inventory_quantity": 1, 
      "weight": 0.0, 
      "weight_unit": "lb", 
      "old_inventory_quantity": 1, 
      "requires_shipping": true 
     }], 
     "options": [{ 
      "id": 9404426823, 
      "product_id": 7874734983, 
      "name": "Title", 
      "position": 1, 
      "values": ["Default Title"] 
     }], 
     "images": [{ 
      "id": 16242879303, 
      "product_id": 7874734983, 
      "position": 1, 
      "created_at": "2016-07-14T10:43:56-04:00", 
      "updated_at": "2016-07-14T10:43:56-04:00", 
      "src": "https://cdn.shopify.com/s/files/1/1363/2407/products/J71227main.jpg?v=1468507436", 
      "variant_ids": [] 
     }], 
     "image": { 
      "id": 16242879303, 
      "product_id": 7874734983, 
      "position": 1, 
      "created_at": "2016-07-14T10:43:56-04:00", 
      "updated_at": "2016-07-14T10:43:56-04:00", 
      "src": "https://cdn.shopify.com/s/files/1/1363/2407/products/J71227main.jpg?v=1468507436", 
      "variant_ids": [] 
     } 
    } 
} 

Unmittelbar danach, ich poste die folgende JSON eine Produktvariante zu diesem neu geschaffenen Teil hinzuzufügen, an die URL „https://key:[email protected]/admin/products/7874734983/variants.json“. Dies ist der Aufruf, der einen 404 - Not Found-Fehler über die Klasse HttpWebRequest zurückgibt.

{ 
    "variant": { 
     "id": 0, 
     "product_id": 7874734983, 
     "title": "Seabreeze Tier Curtain in Sand", 
     "price": "11.99", 
     "sku": "J7122700013V09", 
     "compare_at_price": "0.00", 
     "position": 0, 
     "grams": 0, 
     "option1": "57X13 ROD POCKET VAL", 
     "option2": null, 
     "option3": null, 
     "taxable": true, 
     "barcode": "036326422417", 
     "weight": 0, 
     "weight_unit": "lb", 
     "inventory_quantity": 550, 
     "old_inventory_quantity": 550, 
     "requires_shipping": true, 
     "image_id": null, 
     "metafields": [{ 
      "id": 0, 
      "key": "point1", 
      "value": "57 x 13 Valance", 
      "value_type": "string", 
      "namespace": "J7122700013V09" 
     }, 
     { 
      "id": 0, 
      "key": "point2", 
      "value": "To achieve the look in the photo, use one valance and one tier pair.", 
      "value_type": "string", 
      "namespace": "J7122700013V09" 
     }, 
     { 
      "id": 0, 
      "key": "point3", 
      "value": "Feels like you are in your own beach cottage.", 
      "value_type": "string", 
      "namespace": "J7122700013V09" 
     }, 
     { 
      "id": 0, 
      "key": "point4", 
      "value": "100% Polyester.", 
      "value_type": "string", 
      "namespace": "J7122700013V09" 
     }, 
     { 
      "id": 0, 
      "key": "point5", 
      "value": " ", 
      "value_type": "string", 
      "namespace": "J7122700013V09" 
     }] 
    } 
} 

Was mache ich falsch? Die URLs, wenn sie in einen Webbrowser kopiert werden, funktionieren einwandfrei ... Ich kann den gesamten JSON der aktuellen Daten sehen. Aber wenn ich versuche, die Variante hinzuzufügen, bekomme ich die 404.

Antwort

1

Versuchen Sie die "id": 0 Eigenschaften auslassen - sowohl von der Variante und von den Metafields. Shopify ermittelt die IDs automatisch.

+0

Dies funktionierte für mich, obwohl ich aus irgendeinem Grund nur die Eigenschaft "" id ": 0" aus den Metafields entfernen musste. Ich habe dasselbe mit Produkten, Produktvarianten, Produktbildern und Aufträgen ohne Problem gesendet, aber wenn ich es auf dem Metafeld belasse, wird ein 404 Not Found-Fehler ausgelöst, der unpassend erscheint. Vielen Dank! – RianBattle

+0

"ID" ist nur zu verwenden, wenn Sie etwas aktualisieren. 'variants/ .json' oder' metafields/ .json' – HymnZ