(Quick Reference) Service: Create an objective

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

URL:

https://BASE_URL/api/VERSION/objectives

Method: POST

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
typeType can have only these values 2 if appointments number, 3 if turnover, 4 if item quantityIntegeryes2,3,4
yearA year from 2000 to 2099Integeryes2016
itemIdThe ID of item. Required if objective type is equal to 4(item quantity)Long/String- 
userIdThe ID of userLong/Stringyes 
januaryValue Integer/Doubleno 
februaryValue Integer/Doubleno 
marchValue Integer/Doubleno 
aprilValue Integer/Doubleno 
mayValue Integer/Doubleno 
juneValue Integer/Doubleno 
julyValue Integer/Doubleno 
augustValue Integer/Doubleno 
septemberValue Integer/Doubleno 
octoberValue Integer/Doubleno 
novemberValue Integer/Doubleno 
decemberValue Integer/Doubleno 
useExternalIdBy default, it is set to false. set it to true if you want to use external ids.Booleannotrue , false

If objective type is equal to 4 (item quantity ) or 2 ( appointments number) month value should be an integer
If objective type is equal to 3 (turnover ) month value should be a double

Success Output

Success case: response.status=201
An item must not be goody or asset

{
  "id": 15,
  "employeeReference": "emp-04",
  "employee": {
    "id": 4,
    "reference": "emp-04",
    "href": "/api/v1.0/users/4"
  },
  "itemReference": null,
  "item": null,
  "year": 2017,
  "type": "3",
  "januaryValue": 550.9,
  "februaryValue": 500,
  "marchValue": 100,
  "aprilValue": 110,
  "mayValue": 110,
  "juneValue": 100,
  "julyValue": 700,
  "augustValue": 800,
  "septemberValue": 1000,
  "octoberValue": 600,
  "novemberValue": 300,
  "decemberValue": 300,
  "organization": "entity1",
  "dateCreated": "2016-08-25T13:31:14Z",
  "lastUpdated": "2016-08-25T13:31:14Z"
}

Failure Output

Failure case:response.status = 400
{
  "error": "already_existing",
  "error_description": "Objective is already existing."
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: year (must be a year from 2000 to 2099)"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: year (must be a year greater than or equal to 2017)"
}
{
  "error": "missing_param",
  "error_description": "userId parameter is missing"
}
{
  "error": "missing_param",
  "error_description": "itemId parameter is missing"
}
{
  "error": "invalid_param",
  "error_description": "Item must not be goody or asset"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: januaryValue (must be positive)"
}

Failure case:response.status = 404
{
  "error": "not_found",
  "error_description": "The item with the id 4564 doesn't exist."
}
{
  "error": "not_found",
  "error_description": "The user with the id 4000 doesn't exist."
}

Failure case:response.status = 500
{
    "error": "server_error",
    "error_description": "Oops! Something went wrong..."
}