Announcement

Collapse
No announcement yet.

create custom entity via GET

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • create custom entity via GET

    Hi, as said in the Topic i want to create a custom entity via GET.
    I'm quite new at this, so i dont know how specific I have to be.

    What i have:
    The table 'TestMensch' is of type Person and does have standard attributes.
    I have some code, taken and adapted from one of the other forum entries.

    <?php
    namespace Espo\Modules\Crm\EntryPoints;

    use \Espo\Core\Exceptions\NotFound;
    use \Espo\Core\Exceptions\Forbidden;
    use \Espo\Core\Exceptions\BadRequest;

    class MyCreateEntityEntryPoint extends \Espo\Core\EntryPoints\Base
    {
    public static $authRequired = false;

    public function run()
    {
    $type = $_GET['entityName'];

    $entity = $this->getEntityManager()->getEntity($type);
    $entity->set('assignedUserId', "system");

    if ($type == 'TestMensch') {
    $entity->set('salutationName', $GET['anrede']);
    $entity->set('firstName', $_GET['vorname']);
    $entity->set('lastName', $_GET['nachname']);
    }

    $this->getEntityManager()->saveEntity($entity);
    }
    }

    ?>

    This is put in "Espo\Modules\Crm\EntryPoints"

    I get a 404 Page Not Found Error Message after trying following url

    http://myEspo/?entryPoint=myCreateEn...nachname=Bower

    I only send these 3 attributes in because in the crm userinterface thats the only required fields and the rest got filled up with nothing or automatically.

    Another way would be to simply take the Create Entity function from the api, but i dont know what a payload is, how to create one and how to implement it.

    Questions:
    1. Do i need to send all attributes always even if its not filled?
    note: I did saw the api call in the developer thingy (f12), in which all the attributes were given(even if it was empty), when i created an entity with only these 3 attributes.

    2. What caused the Error exactly and what can I do to make it work?

    3. Can I get a little introduction on payloads, which covers the points mentioned above (optimally with examples)? A beginnerfriendly link should also be enough.

    Thanks in advance for the help.
    Last edited by Hans; 04-12-2018, 08:37 AM.

  • #2
    Hello,
    1. No. It is set in the developer thingy because these fields are on the form.
    2. Check if your entryPoint is in list data/cache/application/entryPoint.php. If not Rebuild CRM in Administration
    3. https://www.espocrm.com/documentatio...-create-entity
    Hi ! Could you please help with the Fatal PHP error on Opportunity creation via API: Espo error_log: [2018-01-25 15:34:44] Espo.WARNING: E_WARNING: Invalid

    Hello, I'm trying to upload contact's document via EspoCRM API v1. The first thing I do is send POST fields to 'api/v1/Attachment'. My POST fields look like this:

    Comment


    • #3
      Thanks for the Information and quick help. The rebuild worked.

      Comment

      Working...
      X