The Sitecore ItemService provides a RESTful API that you use to interact directly with Sitecore items.
import requests sHost = "https://cms.bangtech.com/sitecore/api/ssc/" def JSSGetItem(): sUrl = sHost + "auth/login" print (sUrl) headers = {"Content-Type" : "application/json"} data = {"domain": "sitecore", "username": "uid", "password": "pwd" } # Use 'with' to ensure the session context is closed after use. with requests.Session() as req: # Login resp = req.post(sUrl, headers = headers, json = data) if resp.ok: sText = resp.text print (sText) #print(resp.headers) else: print ("Boo! {}".format(resp.status_code)) print (resp.text) # Get Child Items sUrl = sHost + "item/{C4EA14BD-4F2F-4306-8E7F-A922B9C67E7E}/children?fields=ItemID,ItemName,Active Flag,Search Flag" # /sitecore/content/Global/Facets/Tags print(sUrl) resp = req.get(sUrl) if resp.ok: sText = resp.text print (sText) data = json.loads(sText) for x in data: if x["Active Flag"]=="Y" and x["Search Flag"]=="Y": print(x["ItemName"] + " " + x["ItemID"]); else: print ("Boo! {}".format(resp.status_code)) print (resp.text) JSSGetItem()
Operation |
Query string |
---|---|
Get item |
|
Get item including metadata |
|
Get item including standard template fields |
|
Get item with field projection |
|
Search |
|
Search with paging and field projection |
|
Get media item |
|
Get item using the content path |
|