Skip to content

Writing connections

Jouni Alanen edited this page Aug 21, 2017 · 4 revisions

Example requests & responses - POST, PATCH & DELETE

Create new request - POST /connections

Create new response - POST /connections

Delete request - DELETE /connections/1

Delete response - DELETE /connections/1

Create new request - POST /connections

curl 'http://localhost:3000/v1//connections' \
  -H 'Content-Type: application/vnd.api+json' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: 5e423f7c-8545-4ae9-ad7d-634a7f00e03a' \
  --data-binary '{
    "data": {
      "type": "connections"
      "relationships": {
        "from-diory": {
          "data": {
            "type": "diories",
            "id": "1"
          }
        },
        "to-diory": {
          "data": {
            "type": "diories",
            "id": "2"
          }
        }
      },
    }
  }'

Create new response - POST /connections

201 - Created

{
   "data" : {
      "id" : "1",
      "type" : "connections",
      "links" : {
         "self" : "http://localhost:3000/v1/connections/1"
      },
      "attributes" : {
         "position" : {
            "left" : "220%",
            "width" : "20%",
            "top" : "60%",
            "height" : "20%"
         },
         "from-diory-id" : 1
         "to-diory-id" : 2,
         "room-id" : "diomber-rooms-1",
         "created-at" : "2017-01-06T22:27:40.399+02:00",
         "updated-at" : "2017-01-06T22:27:40.399+02:00",
      },
      "relationships" : {
         "from-diory" : {
            "links" : {
               "related" : "http://localhost:3000/v1/connections/1/from-diory",
               "self" : "http://localhost:3000/v1/connections/1/relationships/from-diory"
            }
         },
         "to-diory" : {
            "links" : {
               "related" : "http://localhost:3000/v1/connections/1/to-diory",
               "self" : "http://localhost:3000/v1/connections/1/relationships/to-diory"
            }
         }
      }
   }
}

Delete request - DELETE /connections/1

curl 'http://localhost:3000/v1//connections/1' \
  -X DELETE \
  -H 'Authorization: 5e423f7c-8545-4ae9-ad7d-634a7f00e03a' \
  -H 'Accept: application/vnd.api+json'

Delete response - DELETE /connections/1

204 - No content

[no response]