Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Retrieve Web Resource Contents in Microsoft CRM 2016 in .NET

Posted on by 270

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

  • Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Retrieve Web Resource Contents in Microsoft CRM 2016 in .NET

    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!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve Web Resource Contents in Microsoft CRM 2016 in .NET

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

  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Retrieve Web Resource Contents in Microsoft CRM 2016 in .NET

    Hi,

    Refer the link below.

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve Web Resource Contents in Microsoft CRM 2016 in .NET

    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/

  • MituCRMing Profile Picture
    MituCRMing 270 on at
    RE: Retrieve Web Resource Contents in Microsoft CRM 2016 in .NET

    Hi Jason,

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

  • Suggested answer
    jlattimer Profile Picture
    jlattimer 24,558 on at
    RE: Retrieve Web Resource Contents in Microsoft CRM 2016 in .NET

    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"));


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans