POST /managers/{id} – REST API

Update a Manager: POST /managers/{id}

Update specific fields for an existing manager.

Query Parameters

  • id: A unique ID for the manager – parameter accepts either the username or email.

URL Parameters
Values should be paramaterized such as using http_build_query() as per example below. Do not include parameters unnecessarily.

  • first_name: Manager’s first name. (If included, can not be empty)
  • last_name: Manager’s last name. (If included, can not be empty)
  • email: Manager’s email, must be unique. (If included, can not be empty)
  • username: Manager’s username, must be unique. Alphanumeric only, 2-15 characters, no spaces. (If included, can not be empty)
  • password: Manager’s password. Minimum 8 characters. (If included, can not be empty)
  • role: Allowed values: admin, basic. Owner’s role can not be changed. (If included, can not be empty)

JSON Result Details
Password is never returned in result set.

  • first_name: Manager’s first name.
  • last_name: Manager’s last name.
  • email: Manager’s email.
  • username: Manager’s username.
  • role: The managerial role for this user.
<?php
$curl = curl_init();

$params = array(
  'first' => 'Scott',
  'username' => 'spilgrim1',
  'role' => 'admin'
);

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.libib.com/managers/sbobomb@example.com?" . http_build_query($params),
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_CONNECTTIMEOUT => 5,
  CURLOPT_TIMEOUT => 15,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "x-api-key: YOUR_API_KEY",
    "x-api-user: YOUR_API_USER"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  $obj = json_decode($response);
}
{
    "first_name": "Scott",
    "last_name": "Pilgrim",
    "email": "sbobomb@example.com",
    "username": "spilgrim1",
    "role": "admin"
}

Was this article helpful?

Related Articles