web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Retrieve Web Resource Contents in Microsoft CRM 2016 in .NET

(0) ShareShare
ReportReport
Posted on by 274

Hello,

I have a Webresoure that is an image and I am trying to retrieve the webresource in .NET (c# code), code is below

Thanks! 

//Test Reteriving Webresource-Image
RetrieveMultipleRequest rmr = new RetrieveMultipleRequest();
RetrieveMultipleResponse resp = new RetrieveMultipleResponse();
Entity wb = resp.EntityCollection.Entities[0];
QueryExpression query = new QueryExpression()
{
EntityName = "webresource",
ColumnSet = new ColumnSet("content"),
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "webresourceid",
Operator = ConditionOperator.Equal,
Values = { "new_image1" }
}
}
}
};
rmr.Query = query;
resp = (RetrieveMultipleResponse)_serviceProxy.Execute(rmr);

byte[] b = Convert.FromBase64String("content");
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,562 on at

    If you know the id - don't use RetrieveMultiple - just use Retrieve

    Entity wr = _client.Retrieve("webresource", new Guid("043081CB-ADE9-E611-8105-C4346BAC1938"), new ColumnSet("content"));
    byte[] b = Convert.FromBase64String(wr.GetAttributeValue<string>("content"));


  • MituCRMing Profile Picture
    274 on at

    Hi Jason,

    Thank you for looking into this, I don't have the ID, since the image/webresource isn't in a form.

  • Community Member Profile Picture
    on at

    Your AttributeName should be name instead of webresourceid.

    Refer this:

    https://nishantrana.me/2015/08/07/sample-code-to-read-xml-data-from-web-resource-in-plugin-in-crm-201120132015/

  • Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    Refer the link below.

    arunpotti.wordpress.com/.../read-xml-web-resource-using-c-sdk-in-crm

  • Community Member Profile Picture
    on at

    You should never retrieve web resources by ID, they're deployed by solution and the ID will change. Use name as a unique identifier.

  • Bipin D365 Profile Picture
    28,983 Moderator on at

    we are trying to set entityimage of contact record from web resource content with above code. it is not working.

    entity.attributes.add("entityimage",convert.frombase64string(content));

    please help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans