(Quick Reference) Service: Create a price

Description: Returns the created price in json format when successful. Returns a json response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/prices

Method: POST

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
itemIdThe numerical ID of itemLong/Stringyes 
unitIdThe numerical ID of unitLong/Stringyes 
priceListIdThe numerical ID of price-listLong/Stringyes 
valueThe price valueDoubleyes 
unitPriceThe unit price valueDoubleno 
marginRateMargin percentageDoubleno 

Success Output

Status: HTTP/1.1 201 Created

{
  "id": 1,
  "priceList": {
    "id": 1,
    "reference": "cost_based_pricing",
    "name": "Cost-based Pricing",
    "href": "/api/v1.0/priceLists/1"
  },
  "itemReference": "bracelet-GRP09062",
  "unitReference": "pcs",
  "itemUnit": {
    "id": 1,
    "href": "/api/v1.0/itemUnits/1"
  },
  "value": 22,
  "unitPrice": 20,
  "marginRate": 10,
  "organization": "entity1",
  "dateCreated": "2015-12-17T08:18:27Z",
  "lastUpdated": "2015-12-17T08:18:27Z"
}

Failure Output

Status: HTTP/1.1 400 Bad Request

{
  "error": "save_failed",
  "error_description": "Failed to save instance"
}
{
  "error": "not_unique",
  "error_description": "Price already used"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: marginRate (must be a Double)"
}

Status: HTTP/1.1 404 Not Found
{
  "error": "not_found",
  "error_description": "The item with the id 4945 doesn't exist."
}
{
  "error": "not_found",
  "error_description": "The unit with the id 123 doesn't exist."
}