siegerts / printful

Printful API Client for Python 3
MIT License
19 stars 6 forks source link

PrintfulAPIException: Server Response 400: No product name #2

Closed yk2kus closed 2 years ago

yk2kus commented 2 years ago

I am trying to create order but unable to understand why the error says No product name. Get commads are working file but post always gives me this error.

URL : 'https://api.printful.com/orders'

called like pf.post(URL, json=order_dict) where order_dict is below json

{'json': {
    'external_id': 28,
    'shipping': 'STANDARD',
    'recipient': {
        'name': 'Gemini Furniture',
        'address1': '317 Fairchild Dr',
        'address2': '',
        'city': 'Fairfield',
        'state_code': 'CA',
        'state_name': 'California',
        'country_code': 'US',
        'country_name': 'United States',
        'zip': '94535',
        'phone': '(941)-284-4875',
        'email': 'gemini.furniture39@example.com',
        'tax_number': False,
        },
    'items': [{
        'id': 1,
        'external_id': 248,
        'variant_id': '3128670962',
        'sync_variant_id': '266252696',
        'external_variant_id': '620589ad6e6fc7',
        'warehouse_product_variant_id': 1,
        'quantity': 1.0,
        'price': '13.00',
        'retail_price': 12.5,
        'name': 'Short-Sleeve Unisex T-Shirt - Black Heather / XS',
        'product': {
            'variant_id': '3128670962',
            'product_id': '266252696',
            'image': 'https://files.cdn.printful.com/products/71/4141_1581412215.jpg'
                ,
            'name': 'Short-Sleeve Unisex T-Shirt - Black Heather / XS',
            },
        'files': [],
        'options': [],
        'sku': '',
        }],
    'retail_costs': {
        'currency': 'USD',
        'subtotal': 14.38,
        'discount': '0',
        'shipping': '5.00',
        'digitization': '0',
        'tax': '0',
        'vat': '0',
        'total': 14.38,
        },
    'gift': {'subject': 'To John', 'message': 'Have a nice day'},
    'packing_slip': {
        'email': 'your-name@your-domain.com',
        'phone': '+371 28888888',
        'message': 'Message on packing slip',
        'logo_url': 'http://www.your-domain.com/packing-logo.png',
        'store_name': 'Your store name',
        },
    }, 'verify': True,
        'headers': {'Authorization': 'Basic YWp5c3djdnktaWV3Mi04bjVrOml1NmwtOW5yeGtrYnZhbDVp',
                    'User-Agent': 'Printful API Python Library 1.2',
                    'Content-Type': 'application/json'}}
yk2kus commented 2 years ago

I was calling wrong URL. :(