/**
  * @NoAdminRequired
  */
 public function addChild()
 {
     $params = $this->request->urlParams;
     $response = new JSONResponse();
     $addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
     try {
         $id = $addressBook->addChild();
     } catch (\Exception $e) {
         return $response->bailOut($e->getMessage());
     }
     if ($id === false) {
         return $response->bailOut(App::$l10n->t('Error creating contact.'));
     }
     $contact = $addressBook->getChild($id);
     $serialized = JSONSerializer::serializeContact($contact);
     if (is_null($serialized)) {
         throw new \Exception(App::$l10n->t('Error creating contact'));
     }
     $response->setStatus('201')->setETag($contact->getETag());
     $response->addHeader('Location', \OCP\Util::linkToRoute('contacts_contact_get', array('backend' => $params['backend'], 'addressBookId' => $params['addressBookId'], 'contactId' => $id)));
     return $response->setParams($serialized);
 }