Uploading Item picture from URL
Views (1842)
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
-
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.
-

Like
Report
*This post is locked for comments