Jump to content

Problem with uploading product


Kassa

Recommended Posts

I'm trying to upload a new product using exsisting data. It basically is a copy of one product but with a new barcode and SKU. When I upload the file using post it just doesnt upload.. Do I need to make more changes to the file before I can use it as a new product?

Link to comment
Share on other sites

import requests

 

productid='placeholder'

url = 'https://api.loyverse.com/v1.0/items/'

headers = {'Authorization' : 'Bearer placeholder'}

newean = '99999999' 

 

json_obj = requests.get(url+productid, headers=headers).json()

 

json_obj['id'] = ''

json_obj['variants'][0]['variant_id'] = ''

json_obj['variants'][0]['sku'] = newean

json_obj['variants'][0]['barcode'] = newean

 

r = requests.post(url,json=json_obj,headers=headers)

 

---------------------------------

I use the json i recieve from the API. I just edit a few entries and then reupload it.

Link to comment
Share on other sites

Sorry don't understand give me an example something like:

request ->

POST https://api.loyverse.com/v1.0/items

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "item_name": "T-shirt",
  "reference_id": "string",
  "category_id": null,
  "track_stock": false,
  "sold_by_weight": false,
  "is_composite": true,
  "use_production": false,
  "components": [
    {
      "variant_id": "8a2d415d-59aa-4132-bef3-011f97c4a0f6",
      "quantity": 0
    }
  ],
  "primary_supplier_id": "dbfc5105-b3ab-4b57-a47f-d7de696f8430",
  "tax_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "modifiers_ids": [
    "string"
  ],
  "form": "SQUARE",
  "color": "GREY",
  "option1_name": "Size",
  "option2_name": "Color",
  "option3_name": null,
  "variants": [
    {
      "variant_id": "8a2d415d-59aa-4132-bef3-011f97c4a0f6",
      "item_id": "4d8cd62e-a579-4dae-af8c-3172f96f8f7c",
      "sku": "string",
      "reference_variant_id": "string",
      "option1_value": "Large",
      "option2_value": "Green",
      "option3_value": null,
      "barcode": "string",
      "cost": 0,
      "purchase_cost": 0,
      "default_pricing_type": "VARIABLE",
      "default_price": null,
      "stores": [
        {
          "store_id": "string",
          "pricing_type": "FIXED",
          "price": 0,
          "available_for_sale": true,
          "optimal_stock": null,
          "low_stock": null
        }
      ]
    }
  ]
}

 

 

Response: 

{

"errors": [

{

"code": "some status",

"details": "some error text will be here"

}

]

}

Link to comment
Share on other sites

{'id': '', 'handle': 'testartikel_api-1', 'reference_id': None, 'item_name': 'Testartikel_API', 'track_stock': False, 'sold_by_weight': False, 'is_composite': False, 'use_production': False, 'category_id': None, 'components': [], 'primary_supplier_id': None, 'tax_ids': ['74aa630b-71b4-11ea-8d93-0603130a05b8'], 'modifier_ids': [], 'form': 'SQUARE', 'color': 'GREY', 'image_url': None, 'option1_name': None, 'option2_name': None, 'option3_name': None, 'created_at': '2020-10-03T11:09:01.001Z', 'updated_at': '2020-10-08T12:34:52.052Z', 'deleted_at': None, 'variants': [{'variant_id': '', 'item_id': 'aa4a2fcb-3802-4b74-96b0-535b1030c9fd', 'sku': '10156', 'reference_variant_id': None, 'option1_value': None, 'option2_value': None, 'option3_value': None, 'barcode': '10156', 'cost': 0.0, 'purchase_cost': None, 'default_pricing_type': 'FIXED', 'default_price': 20, 'stores': [{'store_id': 'f92eb0c5-711d-11ea-8d93-0603130a05b8', 'pricing_type': 'FIXED', 'price': 20, 'available_for_sale': True, 'optimal_stock': None, 'low_stock': None}, {'store_id': 'f92eb0fb-711d-11ea-8d93-0603130a05b8', 'pricing_type': 'FIXED', 'price': 20, 'available_for_sale': True, 'optimal_stock': None, 'low_stock': None}, {'store_id': 'f92eb0aa-711d-11ea-8d93-0603130a05b8', 'pricing_type': 'FIXED', 'price': 20, 'available_for_sale': True, 'optimal_stock': None, 'low_stock': None}], 'created_at': '2020-10-03T11:09:01.001Z', 'updated_at': '2020-10-08T12:34:54.054Z', 'deleted_at': None}]}

 

the id and the variant_id I leave empty so it will become a new product

Link to comment
Share on other sites

Loyverse Point of Sale

 

 

 

 

×
×
  • Create New...