Announcement

Collapse
No announcement yet.

API call - fetch metadata

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

  • API call - fetch metadata

    Hello,

    I would like to ask if its possible to fetch metadata for some field through api?

    I am developing internal helpdesk application, a simple ticket system that transfers tickets from user form to espocrm via API.

    I have field "type" in "case" entity and I need options for this field to be displayed dynamically in form according to how they are set in espo instead of hard coding them in PHP.

    I figured that admin api endpoint for this is https://espo.crm.url/api/v1/Admin/fi...ager/Case/type but API user doesn't have enough rights to access this.

    Any help? Thanks

  • #2
    Code:
    GET Metadata
    Endpoint returns all metadata (available for a user). No other options unless you write your own endpoint.

    Comment


    • #3
      In the CRM create a New User. Under "Teams and Access Control", select "Admin".
      This grants full access, including the ability to create and retrieve API Fields.
      I figured out it won't work with API Users.

      Authenticate and Obtain Auth Token like described here: https://docs.espocrm.com/development/api/
      Perform a GET request to the App/user Endpoint and add the following to the request header:
      Code:
      "Authorization: Basic " + base64Encode(username + ':' + password)
      You will receive an auth token in the response. For future requests, include this in the header:
      Code:
      "Espo-Authorization: " + base64Encode(username + ':' + passwordOrToken)

      Read Field Metadata
      Use a GET request to the following endpoint:
      Code:
      Admin/fieldManager/{Entity}/{field}

      Create New Fields​
      Use a PATCH request to create new fields.
      The new field name must be in the URL, like in the GET Request.
      Include the following in your POST content:json
      Code:
      {
          "name": "newTextField",
          "type": "varchar",
          "label": "New Text Field",
          "entity": "{Entity}",
          "isCustom": true,
          "required": false
      }

      Comment

      Working...
      X