Creating Properties

Last updated: November 5th, 2019

Introduction

In this tutorial we will create a new Accommodation inside Octorate

Required knowledge / points:
  • You MUST have read the start guide carrefully.
  • You should know how HTTP APIs works
  • It's suggested to be confident with tools like curl

Accommodation

Octorate describes an Accommodation by it's relative object. An accommodation could be for instance physical like two different located appartment or logical if the user needs to configure the rooms in different basic settings (i.e. an external service require two access for different rooms)

With your ApiKey you're entitled to create many properties inside Octorate.

Just for reference, let's resee how networks, accommodations and rooms interact toghether.

How Property networks works?

Let's make it work

Take care of schemas

Seeing our swagger documentation , when the API requires in body a JSON encoded text, near every json example, in the request body, you have a small tab voice called "Schema". Click it to see a description of each field

Step One: Send a property

Example of a call Try it / See updated schema
curl -X POST "{endpoint}/rest/accommodation" -H "Content-Type: application/json" -d {followingjson} -H "Authorization: Basic {base64 credentials}" -H "key: {yourkey}"

{
  "website": "www.mycompany.com",
  "zipCode": "00199",
  "city": "Roma",
  "given_name": "Oscar",
  "family_name": "Slim Dogg T",
  "name": "Surf House Lisboa",
  "latitude": 41.1212,
  "longitude": 40.3232,
  "email": "myname@mycompany.com",
  "phone": "+393347608861",
  "address": "Avenida da Liberdade 12",
  "isoCountry": "IT",
  "isoCurrency": "EUR"
}
                                            

Remember that the country and currency codes are the ISO codes

Information about the response

Successfull Response

{
  "codice": [
    "116735"
  ],
  "status": "created"
}
                                            

The response here could be the new property (status created) or the id of previously created properties

Case of unsucessfull response and way to resolve
400 Like responses

{
  "element": "AccommodationForm",
  "message": "Field Information is required.",
  "nested": [
    {
      "human_name": "Latitude",
      "machine_name": "$.latitude",
      "message": "Field Latitude is required.",
      "type": "RejectRequired"
    },
    {
      "human_name": "Longitude",
      "machine_name": "$.longitude",
      "message": "Field Longitude is required.",
      "type": "RejectRequired"
    }
  ],
  "type": "ApiParamsExemption"
}
                                            

As the type information specify, some params could not be accepted. Prepare your application to process the information inside nested.

Tip: You can try to pass "Accept-Language:{ISO 2 LANG}" to check if a translation to your language is available

403/401 Like responses

{
  "nested": [],
  "type": "ApiKeyInvalid"
}
                                            

As the type information specify, you should check that the Api Key you've provided is invalid or check in headers of your call if the key and secrets are inserted