Skip to main content
All CollectionsData Model management
Duplicate an attribute set via API
Duplicate an attribute set via API
Lucien Berkani avatar
Written by Lucien Berkani
Updated over a year ago

To duplicate an attribute set using the Quable APIs, you can use the following Python 3 script to build yours :

import requests

# Set your API endpoints and authentication details
api_url = 'https://your-instance.quable.com'
api_key = 'your-token'
existing_attribute_set_id = 'att_set_dress_skirt'
new_attribute_set_id = 'your_desired_id_for_new_attribute_set'

# Step 1: Retrieve Existing Attribute Set
get_response = requests.get(f'{api_url}/api/attribute-sets/{existing_attribute_set_id}', headers={'Authorization': f'Bearer {api_key}'})
if get_response.status_code == 200:
existing_attribute_set = get_response.json()

# Change the Name and Set a Custom ID
existing_attribute_set['name']['fr-FR'] = 'Nouveau Nom Jeu d\'attribut'
existing_attribute_set['name']['en-US'] = 'New Attribute Set Name'
existing_attribute_set['id'] = new_attribute_set_id

# Step 2: Create a New Attribute Set with Modified Data
post_response = requests.post(f'{api_url}/api/attribute-sets', json=existing_attribute_set, headers={'Authorization': f'Bearer {api_key}'})

if post_response.status_code == 201:
print(f"New attribute set created with ID: {new_attribute_set_id}")
else:
print(f"Failed to create a new attribute set. Status code: {post_response.status_code}")
else:
print(f"Failed to retrieve the existing attribute set. Status code: {get_response.status_code}")

Keywords: Attribute sets, duplicate, duplication, APIs

Did this answer your question?