dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
858 stars 467 forks source link

[REST] Way to retrieve and set Image/File Fields is inconsistent #14418

Closed joseorsini closed 4 years ago

joseorsini commented 6 years ago

Our current REST API endpoint for retrieving and saving/updating contents with Image File fields is working in an inconsistent manner. As per our documentation:

https://dotcms.com/docs/latest/save-content-using-the-rest-api#headerFormats

an Image/File field needs to be set by passing in a string like the following

//demo.dotcms.com/images/photos/The-Gherkin-London-England.jpg

however, upon retrieving a content with this field type, the value we get is a content identifier:

https://demo.dotcms.com/api/content/query/+contentType:CalendarEvent%20+CalendarEvent.title:*Wealth*

Returns this

{"contentlets":[{"modDate":"2017-05-10 17:07:54.219","endDate":"2017-11-10 13:00:00.0","description":"<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.<\/p>\n<p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.<\/p>\n<p>Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.<\/p>\n<p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.<\/p>\n<p>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.<\/p>","title":"Wealth Management Annual Client Meeting","recurrenceDayOfWeek":4,"inode":"da45088c-0096-4300-8c25-1a2ff07c00ae","recurrenceEnd":"2017-05-10 00:00:00.0","recurrenceDayOfMonth":0,"host":"48190c8c-42c4-46af-8d1a-0cd5db894797","lastReview":"2017-05-10 17:07:54.21","recurrenceStart":"2017-11-10 12:00:00.0","categories":"Seminars","stInode":"f6259cc9-5d78-453e-8167-efd7b72b2e96","recurrenceWeekOfMonth":2,"recurs":false,"owner":"dotcms.org.1","identifier":"66d47ebf-7b11-4076-85b0-b6c8c373d000","image":"9e885f4d-1295-4167-975b-afdab2029025","noRecurrenceEnd":false,"urlTitle":"wealth-management-annual-client-meeting","languageId":1,"recurrenceDaysOfWeek":"1,2,3,4,5,6,7,","tags":"meeting,corporate event","recurrenceInterval":0,"folder":"SYSTEM_FOLDER","recurrenceMonthOfYear":5,"sortOrder":0,"modUser":"dotcms.org.1","startDate":"2017-11-10 12:00:00.0"}]}

where the image field contains only its identifier:

"image":"9e885f4d-1295-4167-975b-afdab2029025"

By pulling the image via REST

https://demo.dotcms.com/api/content/query/+identifier:9e885f4d-1295-4167-975b-afdab2029025

We still lack the file's URI, and for generating the Site Info, we would need an additional REST API call for that:

https://demo.dotcms.com/api/content/query/+identifier:48190c8c-42c4-46af-8d1a-0cd5db894797

This is far from ideal when it comes to retrieving contents with this field type, because the content editor does not have a way to set this field properly and make changes to persist once the content is saved/updated.

Expected Behavior

There are a few ways to proceed here:

Or

Current Behavior

Content may get saved in an improper way if we do not pass in the file URL as stated in our documentation. Passing in the content identifier only does not work as well.

Known Workarounds

None.

Context

Reported by customer https://dotcms.zendesk.com/agent/tickets/95857

Your Environment

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had activity within the past 90 days. It will be closed in 30 days no further activity occurs. Thank you.

ygor-sk commented 4 years ago

Well, not even a comment from DotCMS creators. I have hard time uploading and fetching Content with File fields as well. But looking at this ticket, I won't even bother reporting my issue. I will just do it the DotCMS way - the hard way - invent some crazy workaround contraption nr. 55.