Relationship attributes in POST body

We have following response in JSON:API format for GET

GET api/v1//book/123

{
	"data": {
		"type": "book",
		"id": "123",
		"attributes": {
			"name": "Origin"
		},
		"relationships": {
			"author": {
				"type" : "person",
				"id": "123"
			}
		},
		"included": [{
			"type" : "person",
			"id": "123",
			"attributes": {
				"name": "Dan Brown"
			}
		}]
	}
}

for POST input body how should we place the attributes for author

One possible way I could think of is the following

POST api/v1/book

{
	"data": {
		"type": "book",
		"attributes": {
			"name": "Origin"
		},
		"relationships": {
			"author": {
				"type" : "person",
				"attributes": {
					"name": "Dan Brown"
				}
			}
		}
	}
}
2 Likes

Unfortunately, the spec currently doesn’t support this. It’s heavily requested and discussed, though. Search this forum and the GitHub issues for phrases like “sideposting”, “sideloading” and “post related”, and you’ll get many relevant results. :slight_smile:

2 Likes