Campaign Folders

This chapter focuses on services for the campaign folders.

Get all campaign folders

A GET to /campaign-folders returns all the campaigns folders that the user is allowed to read.

HTTP request

GET /api/rest/latest/campaign-folders?page=1&size=3 HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

page

number of the page to retrieve (optional)

size

size of the page to retrieve (optional)

sort

which attributes of the returned entities should be sorted on (optional)

fields

which fields of the elements should be returned (optional)

type

which type of the element should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1390

{
  "_embedded" : {
    "campaign-folders" : [ {
      "_type" : "campaign-folder",
      "id" : 100,
      "name" : "qualification",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/campaign-folders/100"
        }
      }
    }, {
      "_type" : "campaign-folder",
      "id" : 101,
      "name" : "CP-18.01",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/campaign-folders/101"
        }
      }
    }, {
      "_type" : "campaign-folder",
      "id" : 102,
      "name" : "DX-U17",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/campaign-folders/102"
        }
      }
    } ]
  },
  "_links" : {
    "first" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders?page=0&size=3"
    },
    "prev" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders?page=0&size=3"
    },
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders?page=1&size=3"
    },
    "next" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders?page=2&size=3"
    },
    "last" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders?page=3&size=3"
    }
  },
  "page" : {
    "size" : 3,
    "totalElements" : 10,
    "totalPages" : 4,
    "number" : 1
  }
}

Response fields

Path Type Description

_embedded.campaign-folders

Array

the list of elements for that page

page.size

Number

the page size for that query

page.totalElements

Number

total number of elements the user is allowed to read

page.totalPages

Number

how many pages can be browsed

page.number

Number

the page number

_links

Object

related links

Relation Description

first

link to the first page (optional)

prev

link to the previous page (optional)

self

link to this page

next

link to the next page (optional)

last

link to the last page (optional)

Get campaign folders tree by project

A GET to /campaign-folders/tree/{ids} returns the campaigns folders tree by projects that the user is allowed to read.

HTTP request

GET /api/rest/latest/campaign-folders/tree/10,11 HTTP/1.1
Accept: application/json
Host: localhost:8080

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 691

[ {
  "_type" : "project",
  "id" : 10,
  "name" : "project-1",
  "folders" : [ {
    "_type" : "campaign-folder",
    "id" : 100,
    "name" : "folder1",
    "url" : "http://localhost:8080/api/rest/latest/campaign-folders/100",
    "children" : [ ]
  }, {
    "_type" : "campaign-folder",
    "id" : 101,
    "name" : "folder2",
    "url" : "http://localhost:8080/api/rest/latest/campaign-folders/101",
    "children" : [ ]
  } ]
}, {
  "_type" : "project",
  "id" : 11,
  "name" : "project-2",
  "folders" : [ {
    "_type" : "campaign-folder",
    "id" : 102,
    "name" : "folder3",
    "url" : "http://localhost:8080/api/rest/latest/campaign-folders/102",
    "children" : [ ]
  } ]
} ]

Response fields

Path Type Description

[]._type

String

the type of the entity

[].id

Number

id of project

[].name

String

name of project

[].folders

Array

all folders for the given project

[].folders[]._type

String

the type of the entity

[].folders[].id

Number

id of the campaign folder

[].folders[].name

String

name of the campaign folder

[].folders[].url

String

url of the campaign folder

[].folders[].children

Array

children folders

Create campaign folder

A POST to /campaign-folders creates a new campaign folder. The parent object and the name are required; refer to the complete reference of Get campaign folder for the other attributes.

HTTP request

POST /api/rest/latest/campaign-folders HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 203
Host: localhost:8080

{
  "_type" : "campaign-folder",
  "name" : "Campaign folder 1",
  "custom_fields" : [ {
    "code" : "cuf1",
    "value" : "Cuf1 Value"
  } ],
  "parent" : {
    "_type" : "project",
    "id" : 14
  }
}

HTTP response

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 1366

{
  "_type" : "campaign-folder",
  "id" : 33,
  "name" : "Campaign folder 1",
  "project" : {
    "_type" : "project",
    "id" : 14,
    "name" : "Test Project 1",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/14"
      }
    }
  },
  "path" : "/Test Project 1/Campaign folder 1",
  "parent" : {
    "_type" : "project",
    "id" : 14,
    "name" : "Test Project 1",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/14"
      }
    }
  },
  "created_by" : "admin",
  "created_on" : "2017-06-15T10:00:00.000+00:00",
  "last_modified_by" : "admin",
  "last_modified_on" : "2017-06-15T10:00:00.000+00:00",
  "description" : null,
  "custom_fields" : [ {
    "code" : "cuf1",
    "label" : "Lib Cuf1",
    "value" : "Cuf1 Value"
  }, {
    "code" : "cuf2",
    "label" : "Lib Cuf2",
    "value" : "true"
  } ],
  "attachments" : [ ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/33"
    },
    "project" : {
      "href" : "http://localhost:8080/api/rest/latest/projects/14"
    },
    "content" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/33/content"
    },
    "attachments" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/33/attachments"
    }
  }
}

Get campaign folder

A GET to /campaign-folders/{id} returns the campaign folder with the given id.

Path parameters

Table 1. /api/rest/latest/campaign-folders/{id}
Parameter Description

id

the id of the campaign case folder

HTTP request

GET /api/rest/latest/campaign-folders/24 HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1380

{
  "_type" : "campaign-folder",
  "id" : 24,
  "name" : "old",
  "project" : {
    "_type" : "project",
    "id" : 10,
    "name" : "Mangrove",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/10"
      }
    }
  },
  "path" : "/Mangrove/old",
  "parent" : {
    "_type" : "project",
    "id" : 10,
    "name" : "Mangrove",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/10"
      }
    }
  },
  "created_by" : "User-1",
  "created_on" : "2011-09-30T10:00:00.000+00:00",
  "last_modified_by" : "admin",
  "last_modified_on" : "2017-06-16T10:00:00.000+00:00",
  "description" : "<p>where all the old campaigns go</p>",
  "custom_fields" : [ {
    "code" : "CF_TXT",
    "label" : "test level",
    "value" : "mandatory"
  }, {
    "code" : "CF_TAGS",
    "label" : "see also",
    "value" : [ "walking", "bipedal" ]
  } ],
  "attachments" : [ ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/24"
    },
    "project" : {
      "href" : "http://localhost:8080/api/rest/latest/projects/10"
    },
    "content" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/24/content"
    },
    "attachments" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/24/attachments"
    }
  }
}

Response fields

Path Type Description

id

Number

the id of the entity

_type

String

the type of the entity

name

String

name of the entity

project

Object

project of the entity

parent

Object

the location of the entity (either a folder or the project if located at the root of the library)

path

String

the path of the entity

created_by

String

user that created the entity

created_on

String

timestamp of the creation (ISO 8601)

last_modified_by

String

user that modified the entity the most recently

last_modified_on

String

timestamp of last modification (ISO 8601)

description

String

description of that entity (html)

attachments

Array

the attachments of that entity

_links

Varies

related links

custom_fields

Array

the custom fields of that campaign folder

custom_fields[].label

String

the label of the custom field

custom_fields[].code

String

the code of the custom field

custom_fields[].value

Varies

the value of the custom field. The value is either a string (for most custom fields), or an array of strings (for multivalued custom fields eg a tag list)

Relation Description

self

the link to this folder

project

the link to its project

content

the link to its content

attachments

the link to its attachments

Modify campaign folder

A Patch to /campaign-folders/{id} modifies the campaign folder with the given id.

HTTP request

PATCH /api/rest/latest/campaign-folders/33 HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 232
Host: localhost:8080

{
  "_type" : "campaign-folder",
  "name" : "Update - Campaign folder 1",
  "description" : "Update - Description Campaign folder 1",
  "custom_fields" : [ {
    "code" : "cuf2",
    "label" : "Cuf-CaC",
    "value" : "true"
  } ]
}

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1420

{
  "_type" : "campaign-folder",
  "id" : 33,
  "name" : "Update - Campaign folder 1",
  "project" : {
    "_type" : "project",
    "id" : 14,
    "name" : "Test Project 1",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/14"
      }
    }
  },
  "path" : "/Test Project 1/Update - Campaign folder 1",
  "parent" : {
    "_type" : "project",
    "id" : 14,
    "name" : "Test Project 1",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/14"
      }
    }
  },
  "created_by" : "admin",
  "created_on" : "2017-06-15T10:00:00.000+00:00",
  "last_modified_by" : "admin",
  "last_modified_on" : "2017-06-15T10:00:00.000+00:00",
  "description" : "Update - Description Campaign folder 1",
  "custom_fields" : [ {
    "code" : "cuf1",
    "label" : "Lib Cuf1",
    "value" : "Cuf1 Value"
  }, {
    "code" : "cuf2",
    "label" : "Lib Cuf2",
    "value" : "true"
  } ],
  "attachments" : [ ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/33"
    },
    "project" : {
      "href" : "http://localhost:8080/api/rest/latest/projects/14"
    },
    "content" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/33/content"
    },
    "attachments" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/33/attachments"
    }
  }
}

Delete campaign folder

A DELETE to /campaign-folders/{ids} deletes one or several campaign folder with the given id(s). Remember that deleting a folder entails that its content is deleted as well !

Path parameters

Table 1. /api/rest/latest/campaign-folders/{ids}
Parameter Description

ids

the list of ids of the campaign folders

HTTP request

DELETE /api/rest/latest/campaign-folders/51,52 HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080

Get campaign folder contents

A GET to /campaign-folders/{id}/content returns the contents of the campaign folder with the given id.

Path parameters

Table 1. /api/rest/latest/campaign-folders/{id}/content
Parameter Description

id

the id of the campaign-folder

HTTP request

GET /api/rest/latest/campaign-folders/180/content HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

page

number of the page to retrieve (optional)

size

size of the page to retrieve (optional)

sort

which attributes of the returned entities should be sorted on (optional)

fields

which fields of the elements should be returned (optional)

include

level of depth of the content that should be returned (optional), available values : root or nested (more info in Parameter 'include' section)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1021

{
  "_embedded" : {
    "content" : [ {
      "_type" : "campaign",
      "id" : 13,
      "name" : "non regression",
      "reference" : "",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/campaigns/13"
        }
      }
    }, {
      "_type" : "campaign",
      "id" : 150,
      "name" : "new features",
      "reference" : "",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/campaigns/150"
        }
      }
    }, {
      "_type" : "campaign-folder",
      "id" : 1467,
      "name" : "non-standard environment acceptance tests",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/campaign-folders/1467"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/campaign-folders/180/content?page=0&size=20"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 3,
    "totalPages" : 1,
    "number" : 0
  }
}

Response fields

Path Type Description

_embedded.content

Array

the list of elements for that page

page.size

Number

the page size for that query

page.totalElements

Number

total number of elements the user is allowed to read

page.totalPages

Number

how many pages can be browsed

page.number

Number

the page number

_links

Object

related links

Relation Description

first

link to the first page (optional)

prev

link to the previous page (optional)

self

link to this page

next

link to the next page (optional)

last

link to the last page (optional)