Announcement

Collapse
No announcement yet.

API Client Implementation in PHP

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

  • API Client Implementation in PHP

    Hi, i would like to know if it is possible to create multiple records in one request to the same module ?

    Thanks in advance


  • #2
    Only if you create your own controller.

    Comment


    • #3
      Hi, yes, it is possible. Either create a custom entryPoint that will accept a collection/array of records and then add code that will iterate through it and create the records. It's not 100 % one request, but at least you would be able to send an array to endpoint (this will be one request) and the logic behind the endpoint will handle the creation.

      For example, assume you would create endpoint like this:


      Then you would send something like this to the endpoint:
      method: POST
      body:
      Code:
      [
      {"accountName": "Test"},
      {"accountName": "Test2"},
      {"accountName": "Test3"}
      ]
      Then the code would iterate through the body and foreach ($accounts as $account) => createAccount($data).

      Comment


      • #4
        Originally posted by alter View Post
        Hi, yes, it is possible. Either create a custom entryPoint that will accept a collection/array of records and then add code that will iterate through it and create the records. It's not 100 % one request, but at least you would be able to send an array to endpoint (this will be one request) and the logic behind the endpoint will handle the creation.

        For example, assume you would create endpoint like this:


        Then you would send something like this to the endpoint:
        method: POST
        body:
        Code:
        [
        {"accountName": "Test"},
        {"accountName": "Test2"},
        {"accountName": "Test3"}
        ]
        Then the code would iterate through the body and foreach ($accounts as $account) => createAccount($data).
        EntryPoint don't support 'POST' method, only 'GET'

        Comment


        • #5
          Originally posted by dimyy View Post

          EntryPoint don't support 'POST' method, only 'GET'
          Ah, alright, that should not be a problem at all. I would recommend after all to create custom api, for example with Express.js (Node.js), or for PHP developers Slim framework/Lumen. Sometimes it's better to create custom api for handling these types of operations -> this way you could easily create POST endpoint for that and the api would be connected to EspoCRM. With this, you would just send the JSON with data to your custom api endpoint and it would do the logic of creating all the accounts from that JSON for example.

          Comment

          Working...
          X