Add Leave Type

Add Leave Type

Purpose

To add new leavetype/location to your organization.

Request URL

https://live.membroz.com/api/leavetypes

Request Method

POST
Note
  • Send authkey in https header
  • You can add only one leavetype per POST request.
  • You must use only Field API names in the input. You can obtain the field API names from Fields metadata API
  • Enterprise customer can replace domain name with their hosting Url. for example https://app.xyz.com/api/leavetypes
  • API will return inserted leavetype data in JSON format or error message.

Request JSON

Attribute Data Type Mandatory Description
leavetypename text yes leavetype/location/company name
currency text
country text
timezone text
city text
companyphone text
contactperson text

Sample Request

curl --location --request POST 'https://live.membroz.com/api/leavetypes' \
--header 'authkey: XXXXXXXXXX' \
--header 'Content-Type: application/json' \
--data-raw ' {   
        "status": "active",
        "title": "Sick Leave",
        "type": "YEARLY",
        "quantity": 5,
        "iscf": false,
        "isdefault": false,
        "createdAt": "2020-09-23T05:36:01.474Z",
        "updatedAt": "2020-09-23T05:36:01.474Z"
    }'
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, " {   \r\n        \"status\": \"active\",\r\n        \"title\": \"Sick Leave\",\r\n        \"type\": \"YEARLY\",\r\n        \"quantity\": 5,\r\n        \"iscf\": false,\r\n        \"isdefault\": false,\r\n        \"createdAt\": \"2020-09-23T05:36:01.474Z\",\r\n        \"updatedAt\": \"2020-09-23T05:36:01.474Z\"\r\n    }");
Request request = new Request.Builder()
  .url("https://live.membroz.com/api/leavetypes")
  .method("POST", body)
  .addHeader("authkey", "XXXXXXXXXX")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
 "https://live.membroz.com/api/leavetypes",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>" {   \r\n        \"status\": \"active\",\r\n        \"title\": \"Sick Leave\",\r\n        \"type\": \"YEARLY\",\r\n        \"quantity\": 5,\r\n        \"iscf\": false,\r\n        \"isdefault\": false,\r\n        \"createdAt\": \"2020-09-23T05:36:01.474Z\",\r\n        \"updatedAt\": \"2020-09-23T05:36:01.474Z\"\r\n    }",
  CURLOPT_HTTPHEADER => array(
    "authkey: XXXXXXXXXX",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
import requests

url = "https://live.membroz.com/api/leavetypes"

payload = " {   \r\n        \"status\": \"active\",\r\n        \"title\": \"Sick Leave\",\r\n        \"type\": \"YEARLY\",\r\n        \"quantity\": 5,\r\n        \"iscf\": false,\r\n        \"isdefault\": false,\r\n        \"createdAt\": \"2020-09-23T05:36:01.474Z\",\r\n        \"updatedAt\": \"2020-09-23T05:36:01.474Z\"\r\n    }"
headers = {
  'authkey': 'XXXXXXXXXX',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
require "uri"
require "net/http"

url = URI("https://live.membroz.com/api/leavetypes")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["authkey"] = "XXXXXXXXXX"
request["Content-Type"] = "application/json"
request.body = " {   \r\n        \"status\": \"active\",\r\n        \"title\": \"Sick Leave\",\r\n        \"type\": \"YEARLY\",\r\n        \"quantity\": 5,\r\n        \"iscf\": false,\r\n        \"isdefault\": false,\r\n        \"createdAt\": \"2020-09-23T05:36:01.474Z\",\r\n        \"updatedAt\": \"2020-09-23T05:36:01.474Z\"\r\n    }"

response = https.request(request)
puts response.read_body
var client = new RestClient("https://live.membroz.com/api/leavetypes");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("authkey", "XXXXXXXXXX");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", " {   \r\n        \"status\": \"active\",\r\n        \"title\": \"Sick Leave\",\r\n        \"type\": \"YEARLY\",\r\n        \"quantity\": 5,\r\n        \"iscf\": false,\r\n        \"isdefault\": false,\r\n        \"createdAt\": \"2020-09-23T05:36:01.474Z\",\r\n        \"updatedAt\": \"2020-09-23T05:36:01.474Z\"\r\n    }",  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Possible Errors

HTTP Status Error Code Message Reason
permission denied 403 You do not have permission

Sample Response

{
    "status": "active",
    "_id": "5f7417952d0fd7365af61007",
    "title": "Sick Leave",
    "type": "YEARLY",
    "quantity": 5,
    "iscf": false,
    "isdefault": false,
    "createdAt": "2020-09-30T05:28:53.179Z",
    "updatedAt": "2020-09-30T05:28:53.179Z"
}
Send Message
Hello!
How can we help!