How can I add a category programatically ?
In postman are examples how to add category into a catalog or how to add a subcategory.
When I am calling AddCategory I am receiving next exception:
{
"@odata.context": "https://localhost:5000/Api/$metadata#Commands/$entity",
"@odata.type": "#Sitecore.Commerce.EntityViews.Commands.DoActionCommand",
"Id": "cd8621751643493f9a0a860db2e98a85",
"ResponseCode": "Error",
"Messages": [
{
"MessageDate": "2018-05-04T08:29:55.7725232Z",
"Code": "ValidationError",
"Text": "Action has failed due to Optimistic Concurrency failure.",
"CommerceTermKey": "OptimisticConcurrencyFailure"
}
],
"Models": [],
"ActionUrl": null
}
I am doing a PUT call to {{ServiceHost}}/{{ShopsApi}}/DoUxAction()
This are my headers:
Content-Type:application/json
ShopName:{{ShopName}}
ShopperId:{{ShopperId}}
Language:{{Language}}
Currency:{{Currency}}
Environment:{{Environment}}
GeoLocation:{{GeoLocation}}
CustomerId:{{CustomerId}}
Authorization:{{SitecoreIdToken}}
This is my body :
{
"@odata.context": "http://localhost:5000/Api/$metadata#Sitecore.Commerce.EntityViews.EntityView",
"@odata.type": "#Sitecore.Commerce.EntityViews.EntityView",
"Name": "Details",
"Policies": [],
"DisplayName": "Details",
"EntityId": "{{CatalogId}}",
"Action": "AddCategory",
"ItemId": "",
"Properties": [
{
"Name": "Version",
"Policies": [],
"DisplayName": "Version",
"Value": "2",
"IsHidden": true,
"OriginalType": "System.Int32",
"IsReadOnly": true,
"UiType": "",
"IsRequired": true
},
{
"Name": "Name",
"Policies": [],
"DisplayName": "Name",
"Value": "PostmanCategory",
"IsHidden": false,
"OriginalType": "System.String",
"IsReadOnly": false,
"UiType": "",
"IsRequired": true
},
{
"Name": "DisplayName",
"Policies": [],
"DisplayName": "Display Name",
"Value": "Postman Category",
"IsHidden": false,
"OriginalType": "System.String",
"IsReadOnly": false,
"UiType": "",
"IsRequired": true
},
{
"Name": "Description",
"Policies": [],
"DisplayName": "Description",
"Value": "Sample category created through Postman",
"IsHidden": false,
"OriginalType": "System.String",
"IsReadOnly": false,
"UiType": "",
"IsRequired": false
},
{
"Name": "IsSearchable",
"Policies": [],
"DisplayName": "Is Searchable",
"Value": "false",
"IsHidden": false,
"OriginalType": "System.Boolean",
"IsReadOnly": false,
"UiType": "",
"IsRequired": false
}
],
"ChildViews": [],
"DisplayRank": 500,
"UiHint": "Flat",
"Icon": "dashboard"
}