- REST API: These APIs allow you to use Standard GET, POST, PUT and they return JSON. Well that is the high level description of them. You can find more in the REST API documentation. We have also created a simple .NET Core Console application called SchBasicCoreConsole which provides a sample of some of the API calls to get you started. You can find the source code as well as the binary in the SchGuild Git repository.
- WebClient SDK: To use the WebClient SDK you require the Nuget packages for it. These are available via MyGet. This article explains how to get the packages. You can find out more in the WebClient SDK documentation. We have created a simple .NET Core Console application which will be available soon. It provides a sample of calling the WebClient SDK to perform some tasks.
Out of the 2 options we highly recommend using the WebClient SDK for a couple reasons. The first being that WebClient SDK handles a lot of the package formatting which can be error prone. The second being that the Script SDK which is used within Sitecore Content Hub itself uses the same object model so most of the code you do for WebClient SDK can be repurposed for Script SDK.
Any MVP will tell you that the best way to figure out how something works is to decompile the DLL and take a look. In the era of Web-based solution, Fiddler is the equivalent . If the API is not mentioned in the documentation or you need access to the actual JSON response rather than the object model, then the WebClient SDK has the Raw method. This method will pass the proper token for you and allow you to do a raw GET, POST, PUT, DELETE asynchronously. It will not pass in all the headers for you but it is quite useful. You can read more in the IRawClient documetation. For an example of how to use it for POST download the SchWebClientCoreConsole from GitHub and look at the GetAllScriptsAsJson method of the WebClientContext class.
If you have any questions about Sitecore Content Hub feel free to email me. Also if you have access to Sitecore Content Hub and want to help us extend these examples or work on some other open source initiatives we have planned then reach out and we can collaborate so everyone can benefit from this on their first integration. You can email me at christopher_williams@epam.com
If you are going to Sitecore Symposium then you will see Jose Dominguez, Brent Pinkstaff and I wearing a "You Had Me At Metadata" t-shirt. Stop us and say hi.
No comments:
Post a Comment