Quantcast
Channel: Kentico CMS for ASP.NET - DevNet - Forums - Version 7.x - API
Viewing all 660 articles
Browse latest View live

RE:detect current users bandwidth


RE:NRE on Tree Traversal

$
0
0
kentico_martind2
Hello,

The reason is that this is new web.config key which developers are preparing for version 8.
Not all the web.config keys are listed in the Developers Guide and probably never will be as some of them are supposed to be used just in a very specific cases. And this web.config key is one of them as this it is related to security and was introduced just with a specific hotfix version.

Best regards,
Martin Danko

Sessions.

$
0
0
paragbaji
Dear Team,

Two Queries for you:

1.
I need to fetch session values from CMS_Sessions table from the Kentico Database.

So far, I have seen APIs to get and set Session values directly from code behind...

Please guide me for the above.

2.

I also have tried... SessionsManager.CurrentSession.SessionUserName.ToString();

My question here is does the SessionUserName in this context comes from CMS_Session table?

Please help.

RE:Sessions.

$
0
0
FroggEye
Why do you need to get them directly from the database table? Have you used the SessionInfo() class and SessionManager to get the info you need?
SessionInfo si = SessionManager.CurrentSession;

RE:Image resizing functionality

$
0
0
belindaharris897-hotmail
I'm not familar with Kentico image resizing program, but I can recommend you this image resizing api of an .net image gallery, you can call the method to program your own image resizing project for it comes from a third party. You can choose to resize image automatically or manually.



RE:Sessions.

$
0
0
paragbaji
Thank you for your reply, seems that I am close enough.

Now, as per your instructions, I have created that si object.

I want to get the si objects SessionUserName.

But it throws, NullReferenceException: Object reference not set to an instance of an object.
---------
My code snippet for your reference:
SessionInfo si = SessionManager.CurrentSession;

string UsrName = si.SessionUserName.ToString();

[and a code behind alert showing UsrName value]

PS: This happens when I preview it in live mode. Normally, the alert would work showing Administrator name.

Should I use
CurrentUser.Username(); 

Does that has to do something regarding sessions?

Or for
si.SessionUserName.ToString();
I need to pass hardcoded values?

Please guide me.

RE:Sessions.

$
0
0
Kentico_RichardS
Hi,

Thank you for your message.

Is the session really what you are looking for? From your description it seems like you want to get the current user name, is that correct?

If this is the case the CMSContext object is holding these information and you can pull them easily. E.g. to get current user name you can use:
string CurrentUserName = CMSContext.CurrentUser.UserName;

Let me know how that works.

Kind regards,
Richard Sustek

RE:Stream file from content tree

$
0
0
kentico_martind2
Hello David,

I'm still not sure what exactly do you imagine under the "stream" but you can try to use our API and search for some helpful method in the API Reference (e.g. DocumentHelper class) or get the data directly from the database table CMS_Document.

Best regards,
Martin Danko

RE:Programatically choose page template

$
0
0
kentico_martind2
Hello,

Please take a look at the following example code which is used to set a page template for a document:
CMS.DocumentEngine.TreeNode folderNode = CMS.DocumentEngine.TreeNode.New("CMS.MenuItem", tree);

// Get the page template
PageTemplateInfo template = PageTemplateInfoProvider.GetPageTemplateInfo("cms.articlelistwithteasers");

if (template != null)
{
int templateId = template.PageTemplateId;
folderNode.DocumentPageTemplateID = templateId;
}

Best regards,
Martin Danko

REST API Update SKU PUT

$
0
0
Joe
Hi,

I am trying to update a SKU_Info's SKUAvailableItems field. I receive a 404 error. Am I sending the PUT request to the wrong URL? Here is my request:

PUT http://www.mysite.com/rest/ecommerce.sku/2 HTTP/1.1
Authorization: Basic xyz
Content-Type: text\xml
Host: www.mysite.com
Content-Length: 74
Expect: 100-continue

<data><COM_SKU><SKUAvailableItems>100</SKUAvailableItems></COM_SKU></data>

Response

HTTP/1.1 404 Not Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
Date: Sat, 30 Nov 2013 16:17:57 GMT
Connection: close
Content-Length: 4881

mysite.com/rest/ecommerce.sku/2 exists. When I visit it, I receive this XML:

<data>
<COM_SKU>
<SKUID>2</SKUID>
<SKUNumber>12345</SKUNumber>
<SKUName>Hard Cover</SKUName>
<SKUDescription>This is a hardcover book.</SKUDescription>
<SKUPrice>10</SKUPrice>
<SKUEnabled>true</SKUEnabled>
<SKUGUID>f1f5826b-f9db-44b4-9224-33f8a8515123</SKUGUID>
<SKUImagePath>
~/getmetafile/85900275-25e3-4125-b33e-0a8536bf7893/200px-Steve_Jobs_by_Walter_Isaacson.aspx
</SKUImagePath>
<SKUSellOnlyAvailable>false</SKUSellOnlyAvailable>
<SKUCustomData/>
<SKUOptionCategoryID>1</SKUOptionCategoryID>
<SKULastModified>2012-05-19T08:07:35.243-07:00</SKULastModified>
<SKUCreated>2012-05-19T08:07:35.117-07:00</SKUCreated>
<SKUSiteID>1</SKUSiteID>
<SKUNeedsShipping>true</SKUNeedsShipping>
<SKUProductType>PRODUCT</SKUProductType>
</COM_SKU>
</data>

RE:Stream file from content tree

$
0
0
david.mavin-sky
Hi,

Its OK I have sorted it now.

You have to connect to the tree provider, grab the document via the Document Helper class and then use the Attachment Manager to get the attachment and retrieve the stream as binary and re-wind it. I was confused about the fact that a document is also an attachment, but have sorted it now. Also the Document Helper get attachment method does not work so I had to use the attachment manager which did work.

Cheers
David

RE:Stream file from content tree

$
0
0
david.mavin-sky
Hi,

By the way if you wanted the binary stream you via a stored procedure or whatever you cannot use Document entity you have to use the attachment entity. So I guess you could get the information out of the Document entity but would have to go to the attachment entity for the binary. Anyway, I have got the raw binary stream now from the API.

Cheers
David

RE:Stream file from content tree

$
0
0
david.mavin-sky
Hi,

Finally on this, I I am not too sure why you are confused with the term stream? Your API actually has a boolean flag which states "Binary Stream" true or false, e.g retrieve binary stream true or false. At the end of the day a stream is simply an IO or Memory stream of bytes[]?

Cheers
David

RE:Stream file from content tree

$
0
0
kentico_martind2
Hi David,

I just want to clarify the "stream" word in your definition because some users under the "stream" imagine just a content of the page, so just wanted to be sure what exactly are you expecting to receive. But as I see, you know exactly what the stream is :)

Best regards,
Martin Danko

RE:MVC route priority

$
0
0
kentico_sandroj
Hello,

We will share the feedback with our developers but MVC support will be much improved in the next version.

Best Regards,
Sandro

RE:REST API Update SKU PUT

$
0
0
kentico_sandroj
Hello,

Are you able to GET and POST? If so, this article may explain why the PUT (and DELETE) would not work. Please let me know if that is the case here.

Best Regards,
Sandro

RE:REST API Update SKU PUT

$
0
0
Joe
Hi,

I am able to perform GET requests, but not POST or PUT requests. I have removed the WebDAV module from the article, however, the issue persists. I also added the verbs to the extensionless urls module in IIS 7.

RE:REST API Update SKU PUT

$
0
0
kentico_sandroj
Hello,

Thank you for confirming that. In that case the issue is likely in the path, have you tried: /rest/ecommerce.sku/currentsite

Also, please review the documentation and ensure the objects are not read-only.

Regards,
Sandro

RE:REST API Update SKU PUT

$
0
0
Joe
Thanks for the info. I did get it to work with POST. I adjusted my web.config and I got it to work:

web.config changes

public bool UpdateStock(string sku, int quantity)
{
COM_SKU theSKU = GetSKUByNumber(sku);
theSKU.SKUAvailableItems = quantity;
string url = m_BaseUrl + String.Format("/rest/ecommerce.sku/{0}", theSKU.SKUID);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

string userP = m_UserName + ":" + m_Password;
byte[] authBytes = Encoding.UTF8.GetBytes(userP).ToArray();
req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(authBytes));


req.Timeout = 30000;
req.Method = "PUT";
req.ContentType = @"text\xml";

string postString = string.Empty;
using (var writer = new StringWriter())
{
new XmlSerializer(theSKU.GetType()).Serialize(writer, theSKU);
postString = writer.GetStringBuilder().ToString();
}


req.ContentLength = Encoding.UTF8.GetByteCount(postString);
using (Stream sw = req.GetRequestStream())
{
byte[] bytes = Encoding.UTF8.GetBytes(postString);
sw.Write(bytes, 0, bytes.Length);
}

HttpWebResponse resp = null;

try
{
resp = (HttpWebResponse)req.GetResponse();


if (resp.StatusCode == HttpStatusCode.Created)
{
return true;
}

}
catch (Exception)
{

}

return false;
}

RE:REST API Update SKU PUT

$
0
0
kentico_sandroj
Great, I am glad you got it to work. Thank you for sharing the solution!

Best Regards,
Sandro
Viewing all 660 articles
Browse latest View live