Main Content

Magnolia Community Forums: Get help with Magnolia: REST Module abilities


  • dandonov
    dandonov
    Full name: Dian Andonov
    Posts: 2
    Last post: Nov 4, 2016 8:23:41 PM
    Registered on: Nov 4, 2016
    REST Module abilities
    #1 by dandonov on Nov 4, 2016 8:02:16 PM

    Hello,

    I have been using extensively the latest Magnolia REST Module for migrating data from older Magnolia installation and older schema into a new one, also activating content via data scripts. It has been working great however lately I am facing the issue of being unable to create a new content node that has a list of subnodes with an http request.
    The content I am unable to create has the following schema:


    {
    "name": "slideshow-rest-3",
    "type": "mgnl:slideshow",
    "path": "/slideshow-rest-3",
    "properties": [
    {
    "name": "authors",
    "type": "String",
    "multiple": true,
    "values": [
    "My author"
    ]
    },
    {
    "name": "description",
    "type": "String",
    "multiple": false,
    "values": [
    "Slideshow Description"
    ]
    },
    {
    "name": "title",
    "type": "String",
    "multiple": false,
    "values": [
    "Slideshow Title "
    ]
    }
    ],
    "nodes": [
    {
    "name": "slides",
    "path": "/slideshow-rest-3/slides",
    "properties": [],
    "nodes": [
    {
    "name": "00",
    "type": "mgnl:contentNode",
    "path": "/slideshow-rest-3/slides/00",
    "identifier": "7f961b38-2ba3-47dc-b401-8db6955f0501",
    "properties": [
    {
    "name": "showAd",
    "type": "Boolean",
    "multiple": false,
    "values": [
    "true"
    ]
    },
    {
    "name": "slideTitle",
    "type": "String",
    "multiple": false,
    "values": [
    "Slide Title 1"
    ]
    }
    ]
    },
    {
    "name": "01",
    "path": "/slideshow-rest-3/slides/01",
    "properties": [
    {
    "name": "slideTitle",
    "type": "String",
    "multiple": false,
    "values": [
    "Slide Title 2"
    ]
    },
    {
    "name": "slideDescription",
    "type": "String",
    "multiple": false,
    "values": [
    "Slide DEscr 2"
    ]
    },
    {
    "name": "description",
    "type": "String",
    "multiple": false,
    "values": [
    "Slide 2 Description"
    ]
    },
    {
    "name": "title",
    "type": "String",
    "multiple": false,
    "values": [
    "Slide 2"
    ]
    }
    ]
    }
    ]
    }
    ]
    }


    As you can see I am building an array of nodes for each slide. This structure get's build in Magnolia when I use the UI form using the following YAML


    - name: slides
    class: info.magnolia.ui.form.field.definition.MultiValueFieldDefinition
    label: Slides
    transformerClass: info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodePropertiesTransformer
    field:
    name: compositeField
    layout: vertical
    class: info.magnolia.ui.form.field.definition.CompositeFieldDefinition
    transformerClass: info.magnolia.ui.form.field.transformer.composite.NoOpCompositeTransformer
    fields:
    - name: slideTitle
    class: info.magnolia.ui.form.field.definition.TextFieldDefinition
    label: Title
    - name: slideDescription
    class: info.magnolia.ui.form.field.definition.TextFieldDefinition
    label: Description
    rows: 4
    - name: showAd
    class: info.magnolia.ui.form.field.definition.CheckboxFieldDefinition
    label: Show Add
    buttonLabel: ""
    - name: image
    class: info.magnolia.ui.form.field.definition.LinkFieldDefinition
    label: Image
    targetWorkspace: dam
    appName: assets
    identifierToPathConverter:
    class: info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator
    contentPreviewDefinition:
    contentPreviewClass: info.magnolia.dam.app.ui.field.DamFilePreviewComponent


    The error I am getting back trying to submit the json above does not have a meaningful message but just "400 Bad request".

    Is this a limitation of the REST module. If not how am I supposed to persist a 2 level deep data structure via the api?

    Thanks

  • dandonov
    dandonov
    Full name: Dian Andonov
    Posts: 2
    Last post: Nov 4, 2016 8:23:41 PM
    Registered on: Nov 4, 2016
    Re: REST Module abilities
    #2 by dandonov on Nov 4, 2016 8:23:41 PM

    I found the following code in magnolia-rest-servces-1.1.2 module, NodeEndpoint.java




    if (repositoryNode.getNodes() != null && !repositoryNode.getNodes().isEmpty()) {
    return Response.status(Response.Status.BAD_REQUEST).build();
    }



    This pretty much answers one of the questions above.

    Can you advice how to achieve what I am looking to do adding a list of nodes to the main node via the REST API?

  • rgange
    rgange
    Full name: Richard Gange
    Posts: 44
    Last post: Dec 13, 2016 8:35:33 AM
    Re: REST Module abilities
    #3 by rgange on Nov 10, 2016 1:07:29 PM

    Hi Dian-

    From your description of the issue I would say you have hit https://jira.magnolia-cms.com/browse/MGNLREST-74.

    Hopefully a fix will come out some. Keep an eye on the issue and vote it up!

    Cheers
    Rich

You don't have the permission to post on this thread

Sign in

To login on this forum, you can use your Magnolia Forge, Support or Partner account, or, below, your Google, Yahoo! or OpenID account. If you have trouble logging in, or any other sort of issue, please let us know in the Meta forum, on the user-list, or simply by email at forum-admin at magnolia-cms dot com.

* Required

... or sign in with:

  • icon http://{your-openid-url}
  • icon
  • icon https://me.yahoo.com/