Kategorie

Operations with products

Operations with Product - GET, INSERT, UPDATE, DELETE

GET all products from store

Request Type: GET

Enter the request URL: http://StoreURL/odata/product

Auth type: Bearer Token - paste the token generated in the previous steps

If configured it without errors, you should get list of products, as presented below.

Get products from store - result

 

GET product by ID

Request Type: GET

Enter the request URL: http://StoreURL/odata/product('ID')

Auth type: Bearer Token - paste the token generated in the previous steps

GET products by ID screen

Filter products
GET /odata/product?$filter

Request Type: GET

Enter the request URL: http://StoreUrl/odata/product?$filter=Name eq 'adidas Consortium Campus 80s Running Shoes'

Auth type: Bearer Token - paste the token generated in the previous steps

It will show you only product which name is equal to "adidas Consortium Campus 80s Running Shoes".

How to add new product
POST /odata/product

Request Type: POST

Enter the request URL: http://StoreURL/odata/product

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page.

URGENT: You don't have to specify all fields. You can add only that fields, which are important for you. Below you will find a full request to add a product. Edit fields which you want, the rest can be removed and they will get a default value. Please note that ProductType is required.

{
"ProductType": "SimpleProduct",
"ParentGroupedProductId": null,
"VisibleIndividually": true,
"Name": "Simple product added via API",
"SeName": "build-your-own-computer-2",
"ShortDescription": "Build it",
"FullDescription": "<p>Fight back against cluttered workspaces with the stylish IBM zBC12 All-in-One desktop PC, featuring powerful computing resources and a stunning 20.1-inch widescreen display with stunning XBRITE-HiColor LCD technology. The black IBM zBC12 has a built-in microphone and MOTION EYE camera with face-tracking technology that allows for easy communication with friends and family. And it has a built-in DVD burner and Sony's Movie Store software so you can create a digital entertainment library for personal viewing at your convenience. Easy to setup and even easier to use, this JS-series All-in-One includes an elegantly designed keyboard and a USB mouse.</p>",
"AdminComment": null,
"ProductTemplateId": "5c32fa9cbe4baf3374f877c0",
"VendorId": null,
"ShowOnHomePage": true,
"MetaKeywords": null,
"MetaDescription": null,
"MetaTitle": null,
"AllowCustomerReviews": false,
"ApprovedRatingSum": 0,
"NotApprovedRatingSum": 0,
"ApprovedTotalReviews": 0,
"NotApprovedTotalReviews": 0,
"ExternalId": null,
"Sku": null,
"ManufacturerPartNumber": null,
"Gtin": null,
"IsGiftCard": false,
"GiftCardType": "Virtual",
"OverriddenGiftCardAmount": null,
"RequireOtherProducts": false,
"RequiredProductIds": null,
"AutomaticallyAddRequiredProducts": false,
"IsDownload": false,
"DownloadId": null,
"UnlimitedDownloads": false,
"DownloadActivationType": "WhenOrderIsPaid",
"MaxNumberOfDownloads": 0,
"DownloadExpirationDays": null,
"HasSampleDownload": false,
"SampleDownloadId": null,
"HasUserAgreement": false,
"UserAgreementText": null,
"IsRecurring": false,
"RecurringCycleLength": 0,
"RecurringTotalCycles": 0,
"RecurringCyclePeriod": "Days",
"IncBothDate": false,
"Interval": 0,
"IntervalUnitType": "Minute",
"IsShipEnabled": false,
"IsFreeShipping": false,
"ShipSeparately": false,
"AdditionalShippingCharge": 0,
"DeliveryDateId": null,
"IsTaxExempt": false,
"TaxCategoryId": null,
"IsTelecommunicationsOrBroadcastingOrElectronicServices": false,
"UseMultipleWarehouses": false,
"WarehouseId": null,
"StockQuantity": 0,
"ManageInventoryMethod": "DontManageStock",
"DisplayStockAvailability": false,
"DisplayStockQuantity": false,
"MinStockQuantity": 0,
"LowStock": false,
"LowStockActivity": "Nothing",
"NotifyAdminForQuantityBelow": 0,
"BackorderMode": "NoBackorders",
"AllowBackInStockSubscriptions": false,
"OrderMinimumQuantity": 0,
"OrderMaximumQuantity": 0,
"AllowedQuantities": null,
"AllowAddingOnlyExistingAttributeCombinations": false,
"NotReturnable": false,
"DisableBuyButton": false,
"DisableWishlistButton": false,
"AvailableForPreOrder": false,
"PreOrderAvailabilityStartDateTimeUtc": null,
"CallForPrice": false,
"Price": 12200,
"OldPrice": 0,
"CatalogPrice": 0,
"ProductCost": 0,
"CustomerEntersPrice": false,
"MinimumCustomerEnteredPrice": 0,
"MaximumCustomerEnteredPrice": 0,
"BasepriceEnabled": false,
"BasepriceAmount": 0,
"BasepriceUnitId": null,
"BasepriceBaseAmount": 0,
"BasepriceBaseUnitId": null,
"UnitId": null,
"MarkAsNew": false,
"MarkAsNewStartDateTimeUtc": null,
"MarkAsNewEndDateTimeUtc": null,
"Weight": 0,
"Length": 0,
"Width": 0,
"Height": 0,
"AvailableStartDateTimeUtc": null,
"AvailableEndDateTimeUtc": null,
"StartPrice": 0,
"AuctionEnded": false,
"DisplayOrder": 0,
"DisplayOrderCategory": 0,
"DisplayOrderManufacturer": 0,
"Published": true,
"CreatedOnUtc": "2019-01-08T12:06:24.3344716+01:00",
"UpdatedOnUtc": "2019-01-08T12:06:24.334472+01:00",
"Sold": 0,
"Viewed": 0,
"OnSale": 0,
"Flag": null,
"Tags": [],
"AppliedDiscounts": [],
"Id": "5c3484301016a30e68c4d902",
"Categories": [],
"Manufacturers": [],
"Pictures": [],
"SpecificationAttribute": [],
"TierPrices": [],
"WarehouseInventory": [],
"AttributeMappings": [],
"AttributeCombinations": []
}

 

How to update product in your store
POST /odata/product

Request Type: POST

Enter the request URL: http://StoreURL/odata/product

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page.

URGENT: Unlike adding a new product, if you want to update the product, you must enter all fields that exist and enter the ID of product which you want update. . You can use JSON presented in the previous chapter.

How to delete product
DELETE /odata/product('id')

Request Type: DELETE

Enter the request URL: http://StoreURL/odata/product('id')

Auth type: Bearer Token - paste the token generated in the previous steps

Please note that in DELETE operations, you will get only "Status: 200 OK" information if the item was successfully deleted.

Update Stock
POST /odata/product('id')/UpdateStock

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/UpdateStock

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction. In the case of UpdateStock, it will be:

{
"WarehouseId":"ID HERE",
"Stock":"QUANTITY HERE"
}

As a result you should get:

Update stock on product

Assign product to category
POST /odata/product('id')/CreateProductCategory

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/CreateProductCategory

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction. In the case of CreateProductCategory, it's more complicated.

CreateProductCategory entity action

In the EntityAction field you will find only information about productCategory parameter, but if you add it to JSON, you will get 404 error. we need to find more details about this parameter, in the $metadata page, search for ProductCategoryDto. 

CreateProductCategory parameter details

Here you will find all parameters which you need to add to JSON, so in this case you should use:

{
"CategoryId":"ID HERE",
"IsFeaturedProduct":"True/False"
}

How to update product category
POST /odata/product('id')/UpdateProductCategory

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/UpdateProductCategory

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction. In the case of UpdateProductCategory, it's more complicated. You need to find specified parameters in the same way as it's described in CreateProductCategory action.

{
"CategoryId":"ID HERE",
"IsFeaturedProduct":"True/False"
}

How to delete product category
POST /odata/product('id')/DeleteProductCategory

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/DeleteProductCategory

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction. In the case of DeleteProductCategory it's just CategoryId.

{
"CategoryId":"ID HERE"
}

How to assign manufacturer to product
POST /odata/product('id')/CreateProductManufacturer

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/CreateProductManufacturer

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction. In the case of CreateProductManufacturer it's more complicated and you should find the specified parameters, it's described in CreateProductCategory method. 

{
"ManufacturerId":"ID HERE",
"IsFeaturedProduct":"True/False"
}

How to update product manufacturer
POST /odata/product('id')/UpdateProductManufacturer

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/UpdateProductManufacturer

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction. In the case of UpdateProductManufacturer it's more complicated and you should find the specified parameters, it's described in CreateProductCategory method above.

{
"ManufacturerId":"ID HERE",
"IsFeaturedProduct":"True/False"
}

How to delete product manufacturer
POST /odata/product('id')/DeleteProductManufacturer

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/DeleteProductManufacturer

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction. In the case of DeleteProductManufacturer it's more complicated and you should find the specified parameters, it's described in CreateProductCategory method above.

{
"ManufacturerId":"ID HERE"
}

How to add product picture
POST /odata/product('id')/CreateProductPicture

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/CreateProductPicture

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction. This method requires more actions from you. First of all, you need to know picture Id, so we need to upload picture first. It's described in Operations with Pictures topic.

You need to know the MIME Type, list of MIME types can be found here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

{
"PictureId":"ID of Picture",
"DisplayOrder":"1",
"MimeType":"MIME type of picture",
"SeoFilename":"",
"AltAttribute":"Alt of product picture",
"TitleAttribute":"Title of product picture"
}

 

How to update product picture
POST /odata/product('id')/UpdateProductPicture

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/UpdateProductPicture

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction.

You need to know the MIME Type, list of MIME types can be found here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

{
"PictureId":"ID of Picture",
"DisplayOrder":"1",
"MimeType":"MIME type of picture",
"SeoFilename":"",
"AltAttribute":"Alt of product picture",
"TitleAttribute":"Title of product picture"
}

 

How to delete product picture
POST /odata/product('id')/DeleteProductPicture

Request Type: POST

Enter the request URL: http://StoreURL/odata/product('ID')/DeleteProductPicture

Auth type: Bearer Token - paste the token generated in the previous steps

Headers: In the Key field enter the Content-Type, in Value field enter the application/json, description is empty.

Body: In the body field you need to enter the proper JSON. Which fields are necessary for specified actions you can check in the bottom of $metadata page, section with EntityAction.

{
"PictureId":"ID of Picture"
}

back to top