Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Registration of a TD gives 500 ERROR - version 10 #40

Open
karaleina opened this issue Apr 8, 2019 · 2 comments
Open

Registration of a TD gives 500 ERROR - version 10 #40

karaleina opened this issue Apr 8, 2019 · 2 comments

Comments

@karaleina
Copy link

karaleina commented Apr 8, 2019

I created Postman client based on Swagger documentation (api.json file) and tried to register new thing. I got 500 ERROR (Problem accessing /td).

(I set up version 10 according to this guideline #33)

This is the thing that I want to register:

{
  "name":"My Lamp",
  "type": "alien-thing",
  "description": "A web connected lamp",
  "properties": {
    "on": {
      "type": "boolean",
      "description": "Whether the lamp is turned on",
      "href": "/things/lamp/properties/on"
    },
    "brightness" : {
      "type": "number",
      "description": "The level of light from 0-100",
      "minimum" : 0,
      "maximum" : 100,
      "href": "/things/lamp/properties/brightness"
    }
  },
  "actions": {
    "toggle": {
      "description": "Toggle the lamp on and off"
    }
  },
  "events": {
    "overheating": {
      "description": "The lamp has exceeded its safe operating temperature"
    }
  },
  "links": {
    "properties": "/thing/lamp/properties",
    "actions": "/things/lamp/actions",
    "events": "/things/lamp/events"
  }
}
@karaleina karaleina changed the title Registering new thing gives 500 error - version 10 Registering new thing gives 500 ERROR - version 10 Apr 8, 2019
@karaleina karaleina changed the title Registering new thing gives 500 ERROR - version 10 Registering TD gives 500 ERROR - version 10 Apr 8, 2019
@karaleina karaleina changed the title Registering TD gives 500 ERROR - version 10 Registration of a TD gives 500 ERROR - version 10 Apr 8, 2019
@6d77
Copy link
Contributor

6d77 commented Apr 9, 2019

This is definitely due to incompatibilities in your TD:

  • an id is missing
  • the type attribute must be expressed using @type and must contain Thing
  • the href attributes must be part of a form
  • links must be an array of Link elements

The following works:

{
  "name":"My Lamp",
  "@type": [
    "Thing"
  ],
  "id":"urn:thing:MyLamp",
  "description": "A web connected lamp",
  "properties": {
    "on": {
      "type": "boolean",
      "description": "Whether the lamp is turned on",
      "forms": [
        {
          "href": "/things/lamp/properties/on",
          "contentType": "application/json"
        }
      ]
    },
    "brightness" : {
      "type": "number",
      "description": "The level of light from 0-100",
      "minimum" : 0,
      "maximum" : 100,
      "forms": [
        {
          "href": "/things/lamp/properties/brightness",
          "contentType": "application/json"
        }
      ]
    }
  },
  "actions": {
    "toggle": {
      "description": "Toggle the lamp on and off"
    }
  },
  "events": {
    "overheating": {
      "description": "The lamp has exceeded its safe operating temperature"
    }
  },
  "links": [
    {
      "href": "/thing/lamp/properties",
      "rel": "properties"
    },
    {
      "href": "/thing/lamp/actions",
      "rel": "actions"
    },
    {
      "href": "/thing/lamp/events",
      "rel": "events"
    }
  ]
}

@karaleina
Copy link
Author

Thanks, indeed, the TD format was broken (However, it worked with version 9).

Additionally, I had also wrong Content-Type in the header (I should be application/td+json).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants