Skip to content

Latest commit

 

History

History
91 lines (79 loc) · 1.24 KB

update.md

File metadata and controls

91 lines (79 loc) · 1.24 KB

JAD

<< Back

Updating new resource

To update a resource

PATCH /api/v1/jad/genres

Request body:

{
  "data": {
    "type": "genre",
    "id": 26,
    "attributes": {
      "name": "Updated Genre"
    }   
  }
}

Response:

{
  "data": {
    "id":26,
    "type":"genre",
    "attributes": {
      "name":"Updated Genre"
    }
  },
  "links": {
    "self":"http://api/v1/jad/genres"
  }
}

Adding a relationship

PATCH /api/v1/jad/playlist/4

Request body:

{
  "data": {
    "type": "playlist", 
    "relationships": {
      "tracks": {
        "data": {
          "type": "track",
          "id": 422
        }
      }
    }
  }   
}

Response:

{
   "data":{
      "id":4,
      "type":"playlist",
      "attributes":{
         "name":"New Playlist"
      },
      "relationships":{
         "tracks":{
            "links":{
               "self":"http://api/v1/jad/playlist/4/relationship/tracks",
               "related":"http://api/v1/jad/playlist/4/tracks"
            }
         }
      }
   },
   "links":{
      "self":"http://api/v1/jad/playlist/4"
   }
}

Verifying that the track actually have been added to the playlist:

GET /api/v1/jad/playlist/4/relationship/tracks