There is a "headless" addition to umbraco that lets you do this, as well as the older API repo add-on. This is very popular at the moment and is how we use umbraco too
The Rest API package is outdated, which it also says in the GitHub repository and in the documentation here on our. I'll make sure we get Marcin's article at 24days.in/umbraco-cms tagged as "outdated" or something similar so more people don't waste their time and pull their hair out after trying to follow it :-)
Using WebAPI you can make some API endpoints, which can be called from elsewhere.
If you're on the lookout for something that is pure headless and does not need a traditional CMS setup then Umbraco Headless should be released in Q3 2019.
Using WebAPI in this case was the perfect solution.
I have one minor challenge though that I think you might be able to help me with.
I have set up a doctype with some textboxes, a couple of media pickers and a content picker.
I have been able to get the contents from the textboxes and the content picker as strings and in case of the content pickers content made a NiceUrlWithDomain string.
I need to be able to do the same thing with my images from my media pickers, but I haven't been able to. Do you have an idea of how to do this?
Below you can see my (in progress) code for my api method.
[HttpGet, Route("getpromoslides")]
public dynamic GetPromoSlides()
{
var promoSlides = Umbraco.Content(7039);
var list = new List<PromoSlide>();
foreach (var promoSlide in promoSlides.Children)
{
var iconMediaId = promoSlide.GetPropertyValue<int>("icon");
var iconMedia = iconMediaId == 0 ? null : Umbraco.TypedMedia(iconMediaId).Url;
var iconUri = iconMedia == "#" ? null : iconMedia;
var buttonLinkPageId = promoSlide.GetPropertyValue<int>("buttonLink");
var backgroundUriMediaId = promoSlide.GetPropertyValue<int>("backgroundImage");
var backgroundMedia = backgroundUriMediaId == 0 ? null : Umbraco.TypedMedia(backgroundUriMediaId).Url;
var backgroundUri = backgroundMedia == "#" ? null : backgroundMedia;
list.Add(new PromoSlide
{
Icon = iconUri,
ThemeTitle = promoSlide.GetPropertyValue("themeTitle"),
Headline = promoSlide.GetPropertyValue("headline"),
Text = promoSlide.GetPropertyValue("text"),
ButtonText = promoSlide.GetPropertyValue("buttonText"),
ButtonLink = Umbraco.NiceUrlWithDomain(buttonLinkPageId),
BackgroundUri = backgroundUri
});
}
return list;
}
How do I access content from outside of Umbraco
Hi everyone
I would like to access content from outside of Umbraco on a web based system. Is it at all possible and how would one go about doing this?
Is there an API for accessing my content in Umbraco?
There is a "headless" addition to umbraco that lets you do this, as well as the older API repo add-on. This is very popular at the moment and is how we use umbraco too
Thank you.
I will have a look at this in the near future, hopefully it is the answer to my issue.
I have tried installing the Rest API and followed this post (https://24days.in/umbraco-cms/2015/umbraco-rest-api/) but with no luck.
I have not been able to get it running. Is it possible that the post/guide from 24days is missing anything?
FYI: The website is running on an Umbraco v. 7.6.13.
Thanks in advance
Hi Allan
The Rest API package is outdated, which it also says in the GitHub repository and in the documentation here on our. I'll make sure we get Marcin's article at 24days.in/umbraco-cms tagged as "outdated" or something similar so more people don't waste their time and pull their hair out after trying to follow it :-)
Since you already have a site setup I would say that you need to have a look at using WebAPI here https://our.umbraco.com/documentation/Reference/Routing/WebApi/
Using WebAPI you can make some API endpoints, which can be called from elsewhere.
If you're on the lookout for something that is pure headless and does not need a traditional CMS setup then Umbraco Headless should be released in Q3 2019.
Also there is Umbraco HeadRest project by Matt Brailsford using WebAPI that you can explore further here https://github.com/mattbrailsford/umbraco-headrest
/Jan
Hi Jan
Thank you so much. I noticed that the Rest API was discontinued. But I thought it might still worked with my Umbraco installation.
I will definitely give the WebAPI a go and might even have a look at Matt's Umbraco HeadRest project. He usually makes some pretty awesome stuff.
Hi Jan
Using WebAPI in this case was the perfect solution. I have one minor challenge though that I think you might be able to help me with.
I have set up a doctype with some textboxes, a couple of media pickers and a content picker.
I have been able to get the contents from the textboxes and the content picker as strings and in case of the content pickers content made a NiceUrlWithDomain string.
I need to be able to do the same thing with my images from my media pickers, but I haven't been able to. Do you have an idea of how to do this?
Below you can see my (in progress) code for my api method.
Allan,
If you are comfortable with jQuery and javaScript, you can do it this way. This my default method that returns the results in an Array.
var params ={parm1: "value1", param2: "value1" }
passing no params defaults to GET.
is working on a reply...