Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/products/import_file #9

Open
SH-20 opened this issue Aug 12, 2020 · 1 comment
Open

/products/import_file #9

SH-20 opened this issue Aug 12, 2020 · 1 comment

Comments

@SH-20
Copy link

SH-20 commented Aug 12, 2020

Импорт товаров с помощью CSV файла
/products/import_file

$body[] = array(
    'file' => $curlFile,
	'data' => array(
        'force_update' => true,
		'only_available' => false,
		'mark_missing_product_as' => 'none',
		'updated_fields' => array(
			array(
			    'quantity_in_stock'
			)
                )
    )
)

Проблема заключается в том, что сам файл передается но входные параметры force_update и поля которые нужно обновить не воспринимаются. Автоматический подгружается default "price", "presence" можете подсказать где ошибка?

@djecos
Copy link

djecos commented Jun 18, 2022

    url = '/api/v1/products/import_file'
    method = 'POST'

    file = open("final.xml", "rb")
    string_binary = file.read()
    file.close()

    body = {
        "file": string_binary,
        "data": {
            "force_update": True,
            "only_available": True,
            "mark_missing_product_as": "none",
            "updated_fields": [
                "price",
                "presence"
            ]
        }
    }
    return self.make_request(method, url, body)

видає помилку

File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type bytes is not JSON serializable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants