Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-21040

Using 'form-data' create secondary/peer associations on node create

    Details

    • Type: Service Pack Request
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 6.1
    • Fix Version/s: 6.N
    • Component/s: ACS REST API
    • Labels:
    • Environment:
      ACS 6.1.N
    • Bug Priority:
      Category 3
    • ACT Numbers:

      00998616

    • Story Points:
      8

      Description

      Summary

      Unable to create associations using the v1 REST API using form-data

      You can create node with associations using json but no able to use form-data to create a associations.

      Replication Steps

      • create a custom content model type with an association ex.
      <type name="acme:docassoc">
      			<title>Acme Document With Assoc</title>
      			<description>The general content type for Acme documents</description>
      			<parent>cm:content</parent>
      			<properties>
      				<property name="acme:division">
      					<description>Acme Division</description>
      					<type>d:text</type>
      				</property>
      			</properties>
      			<associations>
      				<association name="acme:insert">
      					<title>Insert</title>
      					<source>
      						<mandatory>false</mandatory>
      						<many>true</many>
      					</source>
      					<target>
      						<class&gt;acme:docassoc</class&gt;
      						<mandatory>false</mandatory>
      						<many>true</many>
      					</target>
      				</association>
      			</associations>
      		</type>
      
      • create 3 or more of this type using create node form-data (without associations)

      • use node browser or capture response value of id for these nodes
      • create another node this time adding form fields to create targets to one or more of the nodes created

      • check in node browser for new node and expected associations

      Actual Behavior

      • when using form-data you can select the file to use for you new node (cm:content field), set properties but you can not set the secondary association, associations or any element that is more complex in json create node

      Expected Behavior

      • when using form-data being able to set any json elements in the model schema with th standard array reference syntax such that creation of node in one call includes the file (cm:content) and targets array of values for associations.

      Additional Information

      model schema

      {
        "name": "string",
        "nodeType": "string",
        "aspectNames": [
          "string"
        ],
        "properties": {},
        "relativePath": "string",
        "association": {
          "assocType": "string"
        },
        "secondaryChildren": [
          {
            "childId": "string",
            "assocType": "string"
          }
        ],
        "targets": [
          {
            "targetId": "string",
            "assocType": "string"
          }
        ]
      }
      

      This works if use json body not form-data, but you can not set the cm:content file which is doable when using 'filedata' form field.

      {
        "name": "toaster2",
        "nodeType": "acme:docassoc",
        "targets": [
      {"targetId":"8887795c-e67e-48b7-af23-39a1e89c0840","assocType":"acme:insert"},
      {"targetId":"6cd0049a-b238-432f-a286-8369aee8e195","assocType":"acme:insert"}
        ]
      }
      

      Possibly the syntax is incorrect for the form fields but have tried:

      targets[0][targetId]
      targets[0][assocType]
      

      and

      targets[0]targetId
      targets[0]assocType
      

      and other combinations, does not seem like the REST API handles the proper mapping comparing form-data entry to json entry.

      Workaround

      Two steps min:

      We are not aware of a curl command call that would afford multipart/mixed to afford upload file and using json body to post metadata and associations.

        Attachments

          Issue Links

            Structure

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  jsoria Jennie Soria [X] (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:

                    Structure Helper Panel