/addRelationship: Add Relationship

URL:
https://[root]/content/users/[userName]/addRelationship
Methods:
POST

Example usage

The following is a sample ArcGIS Online POST request for the addRelationship operation:

URL for Add Relationship:

Use dark colors for code blocksCopy
1
2
3
4
5
6
POST /sharing/rest/content/users/jsmith/addRelationship HTTP/1.1
Host: org.arcgis.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

originItemId=a40fddbcd3fc4fadbbb50485a50c3ed0&destinationItemId=b512083cd1b64e2da1d3f66dbb135956&relationshipTypes=Map2Service&f=pjson

The following is a sample ArcGIS Enterprise POST request for the addRelationship operation:

Use dark colors for code blocksCopy
1
2
3
4
5
6
POST /webadaptor/sharing/rest/content/users/jsmith/addRelationship HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

originItemId=a40fddbcd3fc4fadbbb50485a50c3ed0&destinationItemId=b512083cd1b64e2da1d3f66dbb135956&relationshipTypes=Map2Service&f=pjson

Description

The addRelationship operation adds a relationship of a certain type between two items. Relationships are not tied to an item. They are directional links from an origin item to a destination item and have a type. The type defines the valid origin and destination item types as well as some rules. See Relationship types for more information.

Users don't have to own the items they relate unless so defined by the rules of the relationship type. Users can only delete relationships they create. Relationships are deleted automatically if one of the two items is deleted.

Request parameters

ParameterDetails

[Common Parameters]

For a complete listing, see Common parameters.

originItemId

The item ID of the origin item of the relationship.

Example:

Use dark colors for code blocksCopy
1
originItemId=a40fddbcd3fc4fadbbb50485a50c3ed0

destinationItemId

The item ID of the destination item of the relationship.

Example:

Use dark colors for code blocksCopy
1
destinationItemId=b512083cd1b64e2da1d3f66dbb135956

relationshipTypes

The type of relationship between the two items. Must be defined in Relationship types.

Example:

Use dark colors for code blocksCopy
1
relationshipTypes=Map2Service

f

The response format. The default format is html.

Values: html | json | pjson

JSON Response Syntax

Use dark colors for code blocksCopy
1
2
3
{
  "success": <true | false>
}

JSON Response example

Use dark colors for code blocksCopy
1
2
3
{
  "success" : true
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.