{"action":"created","issue":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4439","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4439/labels{/name}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4439/comments","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4439/events","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4439","id":110983209,"number":4439,"title":"[Ready to Review] Change request formatting when creating relationships","user":{"login":"pattisdr","id":9755598,"avatar_url":"https://avatars.githubusercontent.com/u/9755598?v=3","gravatar_id":"","url":"https://api.github.com/users/pattisdr","html_url":"https://github.com/pattisdr","followers_url":"https://api.github.com/users/pattisdr/followers","following_url":"https://api.github.com/users/pattisdr/following{/other_user}","gists_url":"https://api.github.com/users/pattisdr/gists{/gist_id}","starred_url":"https://api.github.com/users/pattisdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattisdr/subscriptions","organizations_url":"https://api.github.com/users/pattisdr/orgs","repos_url":"https://api.github.com/users/pattisdr/repos","events_url":"https://api.github.com/users/pattisdr/events{/privacy}","received_events_url":"https://api.github.com/users/pattisdr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-12T14:17:01Z","updated_at":"2015-10-19T22:04:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/4439","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4439","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/4439.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/4439.patch"},"body":":exclamation: https://github.com/CenterForOpenScience/osf.io/pull/4410 is a dependent\r\n# Purpose\r\nIn an effort to match the json-api spec http://jsonapi.org/format/#crud-creating, we are changing the request format when creating a relationship.  This pertains to node links and contributors.\r\n\r\n- To add a contributor, the user_id and type (users) must be nested under `relationships`\r\n- To add a node link, the target_node_id and type (nodes) must be nested under `relationships`\r\n\r\nIssue: https://openscience.atlassian.net/browse/OSF-4804\r\n\r\n# Changes\r\n\r\n### New Request Formatting\r\n**Creating a contributor:**\r\n```\r\nPOST /v2/nodes/<node_id>/contributors/\r\n{\r\n    'data': {\r\n        'type': 'contributors',\r\n        'attributes': {\r\n            'bibliographic': True,\r\n            'permission': 'read'\r\n        },\r\n        'relationships': {\r\n            'users': {\r\n                'data': {\r\n                    'type': 'users',\r\n                    'id': '<user_id>'\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n**Updating a contributor:**\r\n```\r\nPUT/PATCH /v2/nodes/<node_id>/contributors/<user_id>/\r\n{\r\n    'data': {\r\n        'type': 'contributors',\r\n        'id': '<user_id>',\r\n        'attributes': {\r\n            'bibliographic': False,\r\n            'permission': 'read'\r\n        },\r\n    }\r\n}\r\n```\r\n**Deleting a contributor:**\r\n```\r\nDELETE /v2/nodes/<node_id>/contributors/<contributor_id>/\r\n\r\n```\r\n**Creating a node link:**\r\n```\r\nPOST /v2/nodes/<node_id>/node_links/\r\n{\r\n    'data': {\r\n        'type': 'node_links',\r\n        'relationships': {\r\n            'nodes': {\r\n                'data': {\r\n                    'type': 'nodes',\r\n                    'id': '<target_node_id>'\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n**Deleting a node link:**\r\n```\r\nDELETE /v2/nodes/<node_id>/node_links/<node_link_id>/\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments/149361184","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/4439#issuecomment-149361184","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/4439","id":149361184,"user":{"login":"abought","id":2957073,"avatar_url":"https://avatars.githubusercontent.com/u/2957073?v=3","gravatar_id":"","url":"https://api.github.com/users/abought","html_url":"https://github.com/abought","followers_url":"https://api.github.com/users/abought/followers","following_url":"https://api.github.com/users/abought/following{/other_user}","gists_url":"https://api.github.com/users/abought/gists{/gist_id}","starred_url":"https://api.github.com/users/abought/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abought/subscriptions","organizations_url":"https://api.github.com/users/abought/orgs","repos_url":"https://api.github.com/users/abought/repos","events_url":"https://api.github.com/users/abought/events{/privacy}","received_events_url":"https://api.github.com/users/abought/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T22:04:33Z","updated_at":"2015-10-19T22:04:33Z","body":"This PR has conflicts that need to be resolved. If you ping me when it's ready, I'll pick this up for review first thing in the AM."}}