Skip to content

Basic import request

James Williamson edited this page Jul 17, 2018 · 10 revisions

It is best to start with a basic payload

Properties

  • meta: Contains information to be logged when the import has started.
  • settings: Used to control behaviour during Import.
  • data: Payload such as Companies, People, Users etc are placed in here.
{
  "meta": {
    "created_at": "2018-02-15T17:33:56+0000",
    "feed_name": "The corporation"
  },
  "settings": {
    "version": "0.0.1"
  },
  "data": {
    "people": [],
    "companies": [],
    "users": []
    }
  }
}

People, Companies and Users can contain objects that are imported. You can read more about this here

The Curl request for the API looks like this. You will have to authenticate beforehand. Instructions on how to get an Auth Token can be found here (https://dev.bookingbug.com/docs/rest-api/authentication).

curl -X POST \
  https://the-corporation.bookingbug.com/api/v1/admin/37000/imports \
  -H 'App-Id: XXXXXXX' \
  -H 'App-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'Auth-Token: xxxxxxxxxxxxxxxxxxxxxx' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
  "meta": {
    "created_at": "2018-06-27T09:40:15+01:00",
    "feed_name": "The corporation"
  },
  "settings": {
    "version": "0.0.1"
  },
  "data": {
    "companies": [
      {
        "name": "The name of a store or Branch",
        "external_id": "an_id",
        "object_type": "company",
        "last_modified": "2018-06-24T22:22:28+01:00",
        "status": "live"
      }
    ]
  }
}'

The above request will return you a response describing what happened during the Import Process. An example is shown below. There is also an Asynchronous version of the endpoint available for long running jobs.

{
    "internal_reference": "ec671f68-ed15-407d-8971-a919efab635d",
    "feed_name": "The corporation",
    "created_at": "2018-06-27T09:40:15+01:00",
    "started_at": "2018-06-27T09:40:17+01:00",
    "completed_at": "2018-06-27T09:40:30+01:00",
    "status": "completed",
    "objects_to_import": 1,
    "objects_imported": 1,
    "objects": [
        {
            "status": "created",
            "object_type": "company",
            "object_external_id": "an_id"
        }
    ]
}

Clone this wiki locally