Skip to main content
trungt2435
July 5, 2023
Question

Displaying an Image from External API on Interface Load ?

  • July 5, 2023
  • 5 replies
  • 0 views

Hi,

I want to display an image from an external API call. Currently, I can achieve this on the interface using a button, but it is not ideal. The user wants to load this image from the API on interface/page load without the need to click on the button. Is it possible? Below is the current call I use for the button. thank you.

a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "View API Image",
saveInto: rule!GI_APIExternal_itemImage(
imageNumber: Local!ImageNumber,
onSuccess: {
a!save(local!FTNICallresult, fv!result),
a!save(
local!AppianInternalDocumentID,
rule!LCP_GetNumberOutOfText(local!Callresult.body.imageData)
)
},
onError: {
a!save(
local!CallErrorMessage,
fv!error.message
)
}
),
size: "STANDARD",
style: "NORMAL"
)
},
align: "START"
)

    5 replies

    mathieud0001
    July 5, 2023

    The API would have to return a URL to the image for that to work.

    trungt2435
    July 5, 2023

    oh ok, thank you, yeah it returns a  base64 encoded string of an image, which is why I need to use saveInto so it converts to an image for display back, etc... 

    mikes0011
    Brainy
    July 5, 2023

    I haven't tried this, so I have no idea whether it would really work, but just for the sake of thoroughness, what would happen if you declare a local variable as the result of the API call?

    trungt2435
    July 5, 2023

    it would give me this because inside this call use smartservice to convert base64 into image:  Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error : An error occurred when creating local!CallWebAPI. a!save() and smart service functions cannot be used in a local variable unless "refreshAlways" is true for that local variable using the a!refreshVariable() function.

    mikes0011
    Brainy
    July 6, 2023
    unless "refreshAlways" is true for that local variable

    And if you try using a local variable set to RefreshAlways?