Announcement

Collapse
No announcement yet.

Pull Data From External API

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

  • jflores
    replied
    Ok, I figured it out. You need to add the following property to the $.ajax function:

    Code:
    $.ajax({
      type: "GET",
      url: "https://www.some-url.com/api/...",
      local: true <--- this is the key property,
      headers: {...
    })
    You find the file where the attachment resides at: espocrm/client/src/ajax.js
    Attached Files

    Leave a comment:


  • jflores
    replied
    blueprint - Did you ever manage to the get external call to work? I tried using a 'standard' Backbone.js api call and saw that Espo is appending the URL field to my development root.

    What I'm doing:

    Code:
    $.ajax({
        type: "GET",
        url: "https://www.some-url.com/api/....",
        headers: {​...
    But in the console, what I'm seeing is the GET request looks like this:

    Code:
    http://myespocrmroot.com/api/v1/https://www.some-url.com/api/....
    Maybe I'm using the wrong method to call the API? What did you figure out?

    Leave a comment:


  • blueprint
    commented on 's reply
    Haha, at least someone has confidence in my abilities...

  • blueprint
    commented on 's reply
    This is pretty much what I have at the moment. I've got an Entity which I populate with response data in the Service (rather than populating from the Repository) and this seems to work pretty well. I don't really want to store any duplicate data in EspoCRM as there is a risk that both EspoCRM and GitLab will get out of sync. Will post my solution, probably early next week.

  • telecastg
    replied
    Not sure if it's something that you have considered, or could help, but what about defining a dummy entity in Espo to hold the response data from the API ?.

    You could load the database from the back end and then use a hook to delete the records when the user logs out or upon another event.

    This will allow you to treat the API data as a regular Espo entity with the full Espo functionality.

    Leave a comment:


  • blueprint
    replied
    Thinking about it a bit more, its actually not the Repository where I want to hijack the various CRUD functions, its in the Service class.

    Working on this now and I'm managing to pull out Issues from GitLab and load/filter them into the list view in EspoCRM.

    Leave a comment:


  • telecastg
    commented on 's reply
    Not patronizing, it's an expression of great admiration and confidence in blueprint abilities !
    Last edited by telecastg; 08-06-2020, 06:51 AM.

  • espcrm
    commented on 's reply
    EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.



    application/Espo/Hooks/Integration/GoogleMaps.php
    client/src/views/admin/integrations/google-maps.js
    application/Espo/Core/TemplateHelpers/GoogleMaps.php
    application/Espo/Core/ExternalAccount/Clients/Google.php
    application/Espo/Resources/metadata/integrations/GoogleMaps.json

  • espcrm
    replied
    I'm looking forward to it too! I'm still struggling my head trying to a Mobile phone (Android) app working and still failing to implementing a API parser. It easy to use "Test tool" such as Postman to activate the API and see the response and all that, but to implement with external application outside of CRM is what I'm struggling.

    All guide and tutorial that I read is is done in part or doesn't mention to crucial part to get a working prototype working: Authentication/Custom headers. Worse all, any relevant one that might prove help is for old system or previous version.

    I don't have any tip or input that might be able to help but hopefully these link might be of use:



    If you have those paid extensions https://www.espocrm.com/extensions/
    such as Mailchip, Google or Calling Extension, the source code there might be of usefulness in seeing "how did they do it".

    There is also Google Maps integration as well, that is Free and build in EspoCRM. I think this one is best to start out with.

    ---
    API_ (for forum search keyword)
    Last edited by espcrm; 08-06-2020, 05:45 AM.

    Leave a comment:


  • espcrm
    commented on 's reply
    I like how patronizing this part is: "(I know that you will )"

  • telecastg
    commented on 's reply
    Sounds great ! looking forward to see your solution and your posts :-)

  • blueprint
    replied
    telecastg Hello!

    Well, I’m actually nearly there with the calling of the external API but I’m sure the rest won’t be plain sailing.

    In my custom PHP Repository, I’ve re-implemented several methods marked as abstract in the base Repository/RDB class. Inside these methods, I’m using CURL to call the API and retrieve JSON data - so far, so good.

    The only thing I’m struggling with is mapping the returned API data to my custom Entity/EntityCollection - there are a couple of exceptions which are thrown, I’m yet to figure these out.

    However, you are indeed correct - once I’ve got a working solution, I’ll post back.

    For reference, what I’m doing is implementing a public EspoCRM interface which hooks into the GitLab API for software issue tracking. My custom entity/repository, etc will allow our CRM users to create and view software issues without having a GitLab account.

    Leave a comment:


  • telecastg
    replied
    Hello blueprint

    I think that you would have to implement this at the front end,since Espo is based on Backbone and Backbone defines how a collection is created, including its data sources.

    As I understand the ORM is "representing" the database structure into a "model" that can be manipulated but the data source is already defined, so the changes to the Repository functions would not affect it.

    I am not an expert in Backbone by any means, but my rough understanding is that one of its main purposes is to avoid the immense number of Ajax calls, that would be required to be made from scratch, in a single page application, so Backbone implements and keep track of all of these and that would require Backbone to know/control the external data source .

    I found this article that might steer you in the right direction: https://blog.cloudoki.com/backbone-a...-external-api/

    When you manage to do the implementation (I know that you will ) please share here. This could be a great step to further the development of Espo as a platform for development of custom applications beyond CRM.

    Cheers

    Leave a comment:


  • blueprint
    started a topic Pull Data From External API

    Pull Data From External API

    Has anyone successfully managed to pull entity data from an external API rather than the backend database?

    I have a web service which exposes a REST API. Ideally, I'd like EspoCRM to be the "public" interface to this API so rather than creating/editing/filtering data from the MySQL database, I want to call the external API and "fill in" entity details based on the JSON data returned.

    Any clues as to how this could be possible?

    I've tried overriding the various get/save/remove/find/findOne/getAll Repository functions but this seems to make no difference.
Working...
X