Euth posting empty empty image
In euth there is the process idea_collection, which contains proposals with an optional ImageReference sheet:
If I query the latest version I have the following result:
$ curl http://localhost:6541/opin/idea_collection/proposal_0000002/VERSION_0000000/ | python -m json.tool
{
"content_type": "adhocracy_core.resources.proposal.IProposalVersion",
"data": {
"adhocracy_core.sheets.badge.IBadgeable": {
"assignments": [
"http://localhost:6541/opin/idea_collection/proposal_0000002/badge_assignments/0000000/"
],
"post_pool": "http://localhost:6541/opin/idea_collection/proposal_0000002/badge_assignments/"
},
"adhocracy_core.sheets.comment.ICommentable": {
"comments_count": "0",
"post_pool": "http://localhost:6541/opin/idea_collection/proposal_0000002/comments/"
},
"adhocracy_core.sheets.description.IDescription": {
"description": "asjdajdjasdas",
"short_description": ""
},
"adhocracy_core.sheets.image.IImageReference": {
"external_picture_url": "",
"picture": null,
"picture_description": ""
},
"adhocracy_core.sheets.metadata.IMetadata": {
"creation_date": "2016-05-10T10:05:41.814965+00:00",
"creator": "http://localhost:6541/principals/users/0000000/",
"deleted": "false",
"hidden": "false",
"item_creation_date": "2016-05-10T10:05:41.814965+00:00",
"modification_date": "2016-05-10T10:05:41.814965+00:00",
"modified_by": "http://localhost:6541/principals/users/0000000/"
},
"adhocracy_core.sheets.rate.IRateable": {
"post_pool": "http://localhost:6541/opin/idea_collection/proposal_0000002/rates/"
},
"adhocracy_core.sheets.relation.IPolarizable": {
"polarizations": [],
"post_pool": "http://localhost:6541/opin/idea_collection/proposal_0000002/relations/"
},
"adhocracy_core.sheets.title.ITitle": {
"title": "asdjadajdsjad"
},
"adhocracy_core.sheets.versions.IVersionable": {
"follows": []
}
},
"path": "http://localhost:6541/opin/idea_collection/proposal_0000002/VERSION_0000000/"
}
But posting a new version with just the description updated will lead in an error
> curl 'http://localhost:6541/batch' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json' -H 'X-User-Token: acd2e5e475047fd64d060e3a2d3fc822241d8cf58c48aa939a4f7e5b6ec96ef1b6800006840f4b4da58d00b184a23ea60e7a87000781774886d1d46f5b60d911' --data-binary '[
{
"body": {
"content_type": "adhocracy_core.resources.proposal.IProposalVersion",
"data": {
"adhocracy_core.sheets.description.IDescription": {
"description": "New content"
},
"adhocracy_core.sheets.image.IImageReference": {
"external_picture_url": "",
"picture": null,
"picture_description": "",
"preliminaryNames": {
"state": 12
}
},
"adhocracy_core.sheets.metadata.IMetadata": {
"deleted": false,
"preliminaryNames": {
"state": 12
}
},
"adhocracy_core.sheets.title.ITitle": {
"title": "asdjadajdsjad"
},
"adhocracy_core.sheets.versions.IVersionable": {
"follows": [
"http://localhost:6541/opin/idea_collection/proposal_0000002/VERSION_0000000/"
]
}
},
"parent": "http://localhost:6541/opin/idea_collection/proposal_0000002/",
"root_versions": []
},
"method": "POST",
"path": "http://localhost:6541/opin/idea_collection/proposal_0000002/",
"result_first_version_path": "@pn12",
"result_path": "@pn11"
}
]
' | python -m json.tool
{
"errors": [],
"responses": [
{
"body": {
"errors": [
{
"description": "This Resource does not provide interface adhocracy_core.sheets.image.IImageMetadata",
"location": "body",
"name": "data.adhocracy_core.sheets.image.IImageReference.picture"
}
],
"status": "error"
},
"code": 400
}
],
"status": "error",
"updated_resources": {
"changed_descendants": [],
"created": [],
"modified": [],
"removed": []
}
}
While I understand the error. I think if I fetch an resource and modify it only slightly I should be able to store it back again.
While I understand the error. I think if I fetch an resource and modify it only slightly I should be able to store it back again.
The put requests are meant to change specific data, not to store the whole data back again. In #2283 we started to change this, because its not what you expect and it does not play well with server side rendering.
In this case null should be a valid value for the picture field, looks like a bug.
Anyway mind setting the external_picture_url field, this downloads the referenced image creates a new picture resource.
What happens if you post without the "picture" key?
@joka is null allowed as a value for references?
What happens if you post without the "picture" key?
@joka is null allowed as a value for references?
Yes,