Changing the Data Objects of a Data Provider

Usage

Replaces data objects of the current data source with the ones of the target data source using a given data object mapping and a given strategy. The use of custom strategies is new in the 4.1 SP6 release.

Request
POST /documents/<documentID>/dataproviders/mappings?originDataproviderIds=<dataProviderID[,...]>&targetDatasourceId=<dataSourceID>

Where:

  • <dataProviderID[,...]> is the list of data provider identifiers to consider for the mapping, separated by commas. This parameter is optional.
  • <dataSourceID> is the target data source identifier to use for the proposal mapping. This parameter is mandatory.

Request body: the strategies, the custom mapping, and the parameter values if the document has parameters.

See Mappings Request and Response Body Schemas for request body description.

Request Content

Object Mapping Used

No mapping and strategies

The mapping found by the default strategy

Strategies but no mapping

The mapping found by the strategies

A mapping but no strategies

The mapping overloads the default one

A mapping and strategies

The mapping overloads the one found by the strategies

Response

Response type: application/xml or application/json

The response is a message stating the success or failure of the request.

Example

To Change the Data Source by Providing a Mapping (XML)

POST /documents/9455/dataproviders/mappings?originDataproviderIds=DP0&targetDatasourceId=11414

In the following request body, there are no parameters and all sources are mapped to a target:

<mappings>
    <content>
        <mapping>
            <source>
                <id>DS0.DO12</id>
            </source>
            <target>
                <id>DS1.DO12</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>DS0.DO2</id>
            </source>
            <target>
                 <id>DS1.DO2</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>DS0.DO6</id>
            </source>
            <target>
                <id>DS1.DO39</id>
            </target>
        </mapping>
    </content>
</mappings>

Response:

<success>
    <message>The resource of type "Document" with identifier "9455" has been successfully updated.</message>
    <id>9455</id>
</success>

Example

To Change the Data Source Where one Source is not Mapped to a Target (XML)

POST /documents/9460/dataproviders/mappings?originDataproviderIds=DP0,DP1&targetDatasourceId=11414

In the following request body, there are no parameters and the last source (DS0.DO6) is not mapped to a target. It will be removed from the mapping.

<mappings>
    <content>
        <mapping>
            <source>
                <id>DS0.DO12</id>
            </source>
            <target>
                <id>DS1.DO12</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>DS0.DO2</id>
            </source>
            <target>
                <id>DS1.DO2</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>DS0.DO6</id>
            </source>
            <target/>
        </mapping>
    </content>
</mappings>

Example

To Change the Data Source with a Strategy (JSON)

POST 16706/dataproviders/mappings?originDataproviderIds=DP0&targetDatasourceId=6610

Request body:

{
   "mappings":{
      "policy":{
         "strategies":{
            "strategy":{
               "@name":"SameId"
            }
         }
      },
      "content":{
         "mapping":{
            "source":{
               "id":"M[Measures].[Sales Amount]"
            },
            "target":{
               "id":"M[Measures].[Internet Sales Amount]"
            }
         }
      }
   }
}
Response:
{"success":
    {"message": "The resource of type \"Document\" with identifier \"16706\" has been successfully updated.",
     "id": "16706"
    }
}

Example

To Change the Data Source of a Document with Parameters (XML)

Parameters appear in the response as long as they need to be filled in the request body. When all the parameters have values, then the response is successful.

POST /documents/9460/dataproviders/mappings?originDataproviderIds=DP0,DP1&targetDatasourceId=11414

Request body:

<mappings>
    <content>
        <mapping>
            <source>
                <id>_Vy_yePzREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Product].[Size]</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>_Vy_ye_zREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Employee].[Birth Date]</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>_Vy_yfPzREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Reseller].[Bank Name]</id>
            </target>
        </mapping>
    </content>
</mappings>

The response contains the mapping information and a parameter:

<mappings>
    <content>
        <mapping>
            <source>
                <id>_Vy_yePzREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Product].[Size]</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>_Vy_ye_zREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Employee].[Birth Date]</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>_Vy_yfPzREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Reseller].[Bank Name]</id>
            </target>
        </mapping>
    </content>
    <parameters>
        <parameter optional="false" type="prompt" dpId="DP1">
            <id>0</id>
            <technicalName>psEnter Age:</technicalName>
            <name>Enter Age:</name>
            <answer constrained="false" type="Text">
                <info cardinality="Single"/>
            </answer>
        </parameter>
    </parameters>
</mappings>

Send the following request with the parameter answer:

POST /documents/9460/dataproviders/mappings?originDataproviderIds=DP0,DP1&targetDatasourceId=11414

Request body:

<mappings>
    <content>
        <mapping>
            <source>
                <id>_Vy_yePzREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Product].[Size]</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>_Vy_ye_zREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Employee].[Birth Date]</id>
            </target>
        </mapping>
        <mapping>
            <source>
                <id>_Vy_yfPzREeG4Q-3y4CsnNg</id>
            </source>
            <target>
                <id>A[Reseller].[Bank Name]</id>
            </target>
        </mapping>
    </content>
    <parameters>
        <parameter>
            <id>0</id>
            <answer>
                <values>
                    <value id="1">25</value>
                </values>
            </answer>
        </parameter>
    </parameters
</mappings>
Response:
<success>
    <message>The resource of type "Document" with identifier "9460" has been successfully updated.</message>
    <id>9460</id>
</success>