Get URI language prefix through API

Beau Cowan asked on March 25, 2014 12:09

I'm working on a unique project where we are scraping part of the site based on document selection. I can get the general directories and documents created based off of their URI's just fine, but I want to include the language prefix at the beginning.

Right now I have just 1 language, English. I'm planning on adding more to this later. For now, I want to be able to create the "en" directory for when a URI has something like "/en/foo/bar/". I already have the option selected in the CMSSiteManager to always use a prefix for the urls, but I'm not sure what I need to do to get the rest of this.

Any suggestions?

Recent Answers


Brenden Kehren answered on March 25, 2014 14:15

If you're getting a specific document or tree node you can use the DocumentCulture property or field name in the API. Only difference is it looks like you need "en" vs. what is stored, which is the proper culture, "en-US".

0 votesVote for this answer Mark as a Correct answer

Beau Cowan answered on March 25, 2014 15:54

That's simple enough to do with a substring, thank you. Would be nice to have that as part of the UrlHelper.ResolveURL functionality though.

A new problem that I'm having is that I'm using the HtmlAgilityPack to scrape the pages that I need to be able to package and export, and instead of it pulling up the page, it's going to the login screen. I can't take off the authentication of these pages due to the fact that certain people are only allowed to see them, but how can I get access to them without having to modify the document and then resetting their permissions to what they once were?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 25, 2014 22:30

You might be able to use the REST service built in. OR if you have access to the API, you can do it that way with directly calling the API to get the data for you. OR the last resort and least secure would be to create a "dummy" user and assign all those roles to that user.

0 votesVote for this answer Mark as a Correct answer

Beau Cowan answered on March 26, 2014 15:46

From what I see on the REST services it only allows for XML or JSON to be returned instead of the actual source of the completed document. I need to be able to save out the documents as HTML files.

I'm a little confused by what you mean on access to the API. Do you mean the Kentico API or the HtmlAgilityPack API?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 27, 2014 08:33

I was talking about the Kentico API. This too will only return the actual data and none of the rendered HTML. As I mentioned the last resort would be to create a "dummy" user with permissions and post their login info to get the data from that page.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.