bulkImportCategories
Requires permission categories:category:create.
Imports categories from a CSV or spreadsheet file. By default it only validates the file and reports each row's errors without saving. Set updateExisting to also update categories whose code already exists, which needs permission to update categories. Requires permission to create categories.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation BulkImportCategories($input: BulkCategoryImportInput!) {
bulkImportCategories(input: $input) {
created
failed
success
totalRows
updated
errors {
code
errors
row
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation BulkImportCategories($input: BulkCategoryImportInput!) {\n bulkImportCategories(input: $input) {\n created\n failed\n success\n totalRows\n updated\n errors {\n code\n errors\n row\n }\n }\n}",
"variables": {
"input": {
"fileContent": "string",
"format": "CSV",
"updateExisting": true,
"validateOnly": true
}
}
}
EOF
Variables:
{
"input": {
"fileContent": "string",
"format": "CSV",
"updateExisting": true,
"validateOnly": true
}
}
Response:
{
"data": {
"bulkImportCategories": {
"created": 0,
"failed": 0,
"success": 0,
"totalRows": 0,
"updated": 0,
"errors": [
{
"code": "string",
"errors": [
"string"
],
"row": 0
}
]
}
}
}
bulkImportCategories(
input: BulkCategoryImportInput!
): BulkCategoryImportResult!
Arguments
bulkImportCategories.input ● BulkCategoryImportInput! non-null input
The file content, its format, whether to only validate, and whether to update existing categories.
Type
BulkCategoryImportResult object
The outcome of a category import.