I would like to change the following REST extension from older version to the new API model in version 7.
[RestExtension("Helper")]
public class Helper
{
[RestExtensionMethod(returnXml=false)]
public static string MediaPathById(string id) {
return new Media(int.Parse(id)).getProperty("umbracoFile").Value.ToString();
}
}
I have read the new API documentation and cant figure out the easiest approach to convert this, ideally if possible i would like to do a get with querystring.
public class MediaPathGetter : UmbracoApiController
{
[System.Web.Http.AcceptVerbs("GET")]
[System.Web.Http.HttpGet]
public string MediaPathById() {
var test =0;
var rid= System.Web.HttpContext.Current.Request.QueryString["id"];
if (int.TryParse(rid, out test)) {
return ApplicationContext.Current.Services.MediaService.GetById(int.Parse(rid)).GetValue<string>("umbracoFile");
}
return "invalid request";
}
If I try the above (hacky) code i get invalid keys for the mediaservice.getbyid method when i pass a valid media id.
How to write new API for the old Rest interface?
I would like to change the following REST extension from older version to the new API model in version 7.
I have read the new API documentation and cant figure out the easiest approach to convert this, ideally if possible i would like to do a get with querystring.
If I try the above (hacky) code i get invalid keys for the mediaservice.getbyid method when i pass a valid media id.
Would appreciate if someone can shed light.
is working on a reply...