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 :

Uploading Item picture from URL

Andrey Baludin Profile Picture Andrey Baludin 3,941

Hello Team.

Last week we had a discussion in Yammer about uploading pictures to Item record from URL and in the result I wrote next code. Hope it will be useful for somebody:

    procedure UploadItemPicture(ItemNo: Code[20]; PictureURL: Text)
    var
        Item: Record Item;
        Client: HttpClient;
        Response: HttpResponseMessage;
        InStr: InStream;
    begin
        Client.Get(PictureURL, Response);
        Response.Content().ReadAs(InStr);
        Item.Get(ItemNo);
        Item.Picture.ImportStream(InStr, 'Picture From URL');
        Item.Modify();
    end;

Comments

*This post is locked for comments

  • zaynniiiisdreet Profile Picture zaynniiiisdreet
    Posted at
    I use this code to upload pictures in Pinterest but it get error on second upload.
  • Ferland Profile Picture Ferland
    Posted at
    I use this code to upload pictures in Canva apk but it get error on second upload.
  • MSD_BC_User Profile Picture MSD_BC_User 40
    Posted at
    Hi, I used this code to get the pictures from Sharepoint folder and to import them to the Item pictures. Once the pictures are imported, I am unable to view them in the Business central. I get to see the message 'No Preview available for media content type application/octet-stream' instead of the Picture. Can you please point out where it is going wrong? Thanks.
  • Ghetz Profile Picture Ghetz 3,013
    Posted at
    absolutey useless