Sitecore recently released it’s Item Web API product and I think it will be good for the community to see some sample application. I plan a to do a 3 series blog iteration in the coming weeks, this, being the first one.
- Sitecore Item Web API and Json.Net Test Drive
- Sitecore Item Web API and Json.Net Test Drive (Part II – Strongly Typed)
- Sitecore Item Web API and MonoTouch (iOS development), specifically MonoTouch.Dialog – awesome, awesome framework.
Before moving on, the assumption is you have already installed and configured Sitecore’s Item Web API in your development environment. I can probably cover that as well on a separate blog. It’s really simple, really.
So now that you have Sitecore’s Item Web API installed, you are probably asking yourself what does this new tool provide? In a nutshell, it provides you 3 things:
- Allows client to get Sitecore items based on ID or query. For now, based on my evaluation, it supports Sitecore query and Sitecore fast query. The limitation I saw initially was it does not allow me to include query filters like [@@templatename=’Product’].
- Allows item manipulation (add/update/delete). This is done via the different Http verbs.
- Allows media uploads.
Now that we got that out of the way, let’s look at the existing code below.
- Lines 3 to 10 are just basic variable declarations. It gets the values from the app.config this case.
- Lines 12 to 19 just sets the string variable request based on the value of the query.
- Line 21 downloads the actual request
- Line 23 parses the returned json string using Json.Net. Note the usage of the dynamic keyword. Very powerful stuff.
- If you look at the returned json string, you can see that it contained the items array inside the result.
Here’s a copy of the returned json. Viewed using Chrome and Pretty Json.
Here’s a copy of the app.config
In closing, I’ve only touched the surface of Sitecore’s Item Web API. I’m sure the next releases will build upon this new framework and make it more awesome.