This article provides examples of the GET method using the SystemWeaver Rest API. GET is used to request data and should have no other effect. It can be used together with filtering if needed. 


Prerequisites


GET Without Filtering

Below are example for retrieving items. 


GET a Single Item


URL (verb GET)

/items/x0400000000019FA9


The response will be:

{
"handle": "x0400000000000DE3",
"name": "My cool item",
"type": {
"handle": "x020000000000010F",
"name": "AUTOSAR System",
"sid": "ARLE"
},
"attributes": [],
"creationDate": "2020-06-24T16:45:25.271",
"createdBy": {
"handle": "x0E00000000000003",
"username": "admin",
"name": "admin",
"isActive": true
},
"lastChanged": "2020-06-25T08:15:19.426",
"lastChangedBy": {
"handle": "x0E00000000000003",
"username": "admin",
"name": "admin",
"isActive": true
},
"statusLastChanged": "2020-06-24T16:45:25.271",
"statusLastChangedBy": {
"handle": "x0E00000000000003",
"username": "admin",
"name": "admin",
"isActive": true
},
"ownedBy": {
"handle": "x0E00000000000003",
"username": "admin",
"name": "admin",
"isActive": true
},
"versionText": "",
"versionNumber": "1",
"previousVersion": null,
"nextVersions": [],
"topNode": {
"handle": "x1F00000000000DE4",
"name": "My cool item"
},
"homeLibrary": {
"handle": "x1300000000000317",
"name": "Example from 3102"
},
"ancestorHandle": "x0400000000000DE3",
"status": "Work",
"branching": "Trunk",
"foreignId": "",
"foreignAncestorId": "",
"mergedTo": null,
"parts": []
}


Filtering by Properties, Field Codes and Attributes

You can filter GET responses by item properties, field codes and attributes. Below are some examples. 


Example: Created By

To find all items created by a certain user, add an argument containing the username as a parameter. In this case the username is "admin".


URL (verb GET)

/items?createdBy=admin


The response will be a list of items (in this example, only one item is returned). Only a limited number of properties are returned for each item:

[
{
"handle": "x0400000000000DE3",
"name": "My cool item",
"objectType": "LibraryItem",
"type": {
"handle": "x020000000000010F",
"name": "AUTOSAR System",
"sid": "ARLE"
},
"parts": []
}
]


Example: Creation Date

To find all items created within a certain date, use the filters creationDateFrom and creationDateTo.


URL (verb GET)

/items?creationDateFrom=2020-05-27T07:40

or

/items?creationDateTo=2020-05-27T07:40

or as a combination

/items?creationDateFrom=2020-05-27T07:40&creationDateTo=2020-05-27T07:40


The response is a list of items.


Example: Other Item Property and Field Code Filters

The following filters can be used in a similar way to filter out specific items.


URL (verb GET)

/items?itemhasissues=True

/items?itemhaspartoftype=ARRP

/items?hasnextversion=True

/items?itemstatusequals=I

/items?itemtypeequals=ARAP

/items?foreignancestoridequals=Abc123

/items?nameequals=i3

/items?ownerequals=admin

/items?namecontains=i

/items?versiontextcontains=created

/items?namecontains=i&namecontainscasesensitive=true


The response is a list of items.


You find the full list of filters in the Rest API Documentation:


<Rest Api Url>/Documentation.


Example: Attributes

You can filter GET responses by item attributes as well. Below are some examples. 


URL (verb GET)

/items?attributesContains=abc123

or filter both item type and attribute

/items?itemtypeequals=JSES&attributesContains=abc123

Specify whether to be case sensitive or not when filtering:

/items?attributesContains=abc123&attributescontainscasesensitive=true


The response is a list of items.


Attributevaluein

To find items based on their attributes, you can also use attributevaluein.


URL (verb GET)

Filter items that have an attribute with SID "MTA":

/items?itemhasattribute=MTA

Filter items that have the attribute sid MTA and the attribute value Coolest:

/items?attributevaluein=Coolest&attributevalueinsid=MTA

Both attributes and values can be comma-delimited lists:

/items?attributevaluein=Coolest,One,Two,Three&attributevalueinsid=MTA,OTD


The response is a list of items.


Itemattributecompare

Itemattributecompare is used either with sids/min/max, or with sids/value. SIDs can be a comma-delimited string.


URL (verb GET)


Sid/min/max:

/items?itemattributecomparesid=INTE&itemattributecomparemin=1&itemattributecomparemax=10

or


Sid/value:

/items?itemattributecompare=5&itemattributecomparesid=INTE


The response is a list of items.


Attribute Description

To get the attribute descriptions enter the url below, where TRVS is the attribute SID.


URL (verb GET)

/items/x0400000000017245/attribute/TRVS/rvftext


The response is of the type AttributeRvfTextResponse:

{
"handle": "x0400000000017257",
"attributeSID": "TRVS",
"format": "PlainText",
"description": "abc"
}


Default format is plain text, but you can also choose to recieve the description in RTF format:

/items/x0400000000017384/attribute/TRVS/rvftext?format=RTF


The response will look like this:

{
  "handle": "x0400000000017384",
  "attributeSID": "TRVS",
  "format": "RTF",
  "description": "{\\rtf1\\fbidis\\ansi\\ansicpg0\\uc1\\deff0\\deflang0\\deflangfe0{\\fonttbl{\\f0\\fnil Arial;}}{\\colortbl;\\red0\\green0\\blue255;\\red0\\green0\\blue128;\\red128\\green0\\blue0;\\red0\\green128\\blue0;}\r\n\r\n\r\n\\pard\\fi0\\li0\\ql\\ri0\\sb0\\sa0\\itap0 \\plain \\f0\\fs20 abc\\par}"
}