Documentation
Push employee
A valid and authorized APIKey for a user with granted access must be added to the Request header.
This APIKey is retrieved from /revoke endpoint.
This action is restricted to to granted-access user only.
This action push a new employee on IBP with the fields provided.
To activate a fallback that will first try to send the password by phone message then, if it fails, will be sent by email then you must set the field CBOMailFallback to true
When the fallback CBOMailFallback is set to true, the phone number can be omitted otherwise he is required.
Required fields :
firstname, lastname, school, group, city, [phone]
Optional fields :
email, ionis_id, active, password, email_perso
If the parameter school is not specified, it will be it will be set according to the domain name.
Parameters school and city willl be set as the first affiliated school of the employee.
This will require a JSON request body (be sure to set the Content-Type header to application/json).
Requirements
| Name |
Requirement |
Type |
Description |
| APIKey |
header |
string |
APIKey for authorization |
Return
| Parameter |
Type |
Description |
| data |
JSON array/object |
Errors messages |
| msg |
string |
Message when failure |
| code |
string |
Status code |
Status Codes
| Status Code |
Description |
| 200 |
- Returned when successfull
|
| 201 |
- Returned when successfull with data recorded
|
| 503 |
- Returned when OAI server is unreacheable
|
| 400 |
- Return when incorrect request
|
| 401 |
- Returned when authentication failed (Bad credentials maybe)
|
| 403 |
- Returned when user is not granted for this action
|
Example
URL:
https://oai.epitech.eu/api/employees/push
POST fields:
{
"firstname": "John",
"lastname": "Doe",
"school": "Epitech",
"group": "prof",
"city": "Paris",
"phone": "+33612345678"
}
Request exemple:
PHP
JavaScript (jQuery)
JavaScript (NodeJS)
Python
Ruby
Java (Unirest)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://oai.epitech.eu/api/employees/push",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{'firstname':'John','lastname':'Doe',...}",
CURLOPT_HTTPHEADER => array(
"APIKey: gYm9kckhLnm6o8p3esssfFbr1A7sOGfq",
"content-type: application/json"
)));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
echo "cURL Error #:" . $err;
else
echo $response;
var settings = {
"async": true,
"crossDomain": true,
"url": "https://oai.epitech.eu/api/employees/push",
"method": "POST",
"headers": {
"APIKey": "gYm9kckhLnm6o8p3esssfFbr1A7sOGfq",
"Content-Type": "application/json"
},
"data": {
"firstname": "John",
"lastname": "Doe",
...
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require("request");
var options = { method: 'POST',
url: "https://oai.epitech.eu/api/employees/push",
headers:
{ APIKey: 'gYm9kckhLnm6o8p3esssfFbr1A7sOGfq', Content-Type: "application/json" },
form:
{ firstname: 'John',
lastname: 'Doe',
... } };
request(options, function (error, response, body) {
if (error)
throw new Error(error);
console.log(body);
});
import requests
url = "https://oai.epitech.eu/api/employees/push"
payload = "{'firstname':'John','lastname':'Doe',...}"
headers = {
'APIKey': "gYm9kckhLnm6o8p3esssfFbr1A7sOGfq",
'Content-Type': "application/json"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
require 'uri'
require 'net/http'
url = URI("https://oai.epitech.eu/api/employees/push")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["APIKey"] = 'gYm9kckhLnm6o8p3esssfFbr1A7sOGfq'
request["content-type"] = 'application/json'
request.body = "{'firstname':'John','lastname':'Doe',...}"
response = http.request(request)
puts response.read_body
HttpResponse response = Unirest.get("https://oai.epitech.eu/api/employees/push")
.header("APIKey", "gYm9kckhLnm6o8p3esssfFbr1A7sOGfq")
.header("content-type", "application/json")
.body("{'firstname':'John','lastname':'Doe',...}")
.asString();
Response returned :
{
"data": {
"id": 35465,
"login": "john.doe@epitech.eu"
},
"message":"Employee john.doe@epitech.eu inserted with id : 35465",
"code": 201
}