CenterForOpenScience / SHARE

SHARE is building a free, open, data set about research and scholarly activities across their life cycle.
http://share-research.readthedocs.io/en/latest/index.html
Apache License 2.0
101 stars 58 forks source link

[SHARE-876][Feature] Allow source creation via API #675

Closed laurenbarker closed 7 years ago

laurenbarker commented 7 years ago

Questions for reviewer(s)

  1. Should update be supported for icons only? The way the system currently works, updating the long_title would not be desirable. Is allowing updates to just the icon worth implementing?
  2. Is using long_title submission to create the other username/label/name the best solution?

Purpose

Allow creation of a source with the API. See, https://openscience.atlassian.net/browse/SHARE-876

Changes

Request Content

{
    "data": {
        "type": "Source",
        "attributes": {
            "homePage": "http://super.test.edu",  (optional)
            "longTitle": "Super Test",
            "icon": "<url_for_icon>"
        }
    }
}

Response

{
    "data": {
        "attributes": {
            "home_page": "http://super.test.edu",
            "name": "super_test",
            "long_title": "Super Test"
        },
        "id": "XXXXX-XXX-XXX",
        "relationships": {
            "share_user": {
                "data": {
                    "attributes": {
                        "username": "super_test",
                        "authorization_token": "N2RDMXU397HFIAA19CVZIOM1Q50BUJZQ85WCAFU49WIR46TIYQJ9VZKSLT6AKBXP"
                    },
                    "id": "XXXXX-XXX-XXX",
                    "type": "ShareUser"
                }
            },
            "source_config": {
                "data": {
                    "attributes": {
                        "label": "super_test"
                    },
                    "id": "XXXXX-XXX-XXX",
                    "type": "SourceConfig"
                }
            }
        },
        "type": "Sources"
    }
}

Errors

{
    "errors": [
        {
            "detail": "Could not download/process image. [\"Invalid type. Expected one of ('image/png', 'image/jpeg'). Received text/html\"]",
            "status": "400",
            "source": {
                "pointer": "/data"
            }
        }
    ]
}