Sending documents to external system through a WebAPI call

Hello, Is it possible to send documents to an external system through a WebAPI call? I was playing with http response header 'Content-Disposition' with header value being ' attachment; filename=finename.pdf" '. But I don't get to understand how to embed a document from Appian 'content management system' either as a response header or body. When a call this API with this partial set up, the browser does at-least initiates a file download which I can't open(as I never really attached a file in response!). Is it even possible at all? Should the documents be attached in headers or body and how? Thanks for helping...

Here is the response I'm trying to prepare and see how I've embedded document object inside body. I'm sure this is not how it should be done, but I hope it will convey my intentions.

a!httpResponse(
headers: {
a!httpHeader(
name: "Content-Type",
value: "application/text"
),
a!httpHeader(
name: "Content-Disposition",
value: "attachment; filename=" & char(34) & local!username & ".txt" & char(34)
)
},
body: {
todocument(121330)
}
)

  Discussion posts and replies are publicly visible

  • Hi Jacob, I have a requirement wherein I need to transfer an Appian document from one environment (cloud) to another (one premise). I'm following the method suggested by the link you shared.

    I try to download file using safelink. 

    It works only when I logged in to the other environment from where the document is being sent.

    If I log out, I get AUTHENTICATION FAILED message.

    Is there any way to fix this? 

  • To transfer a document between environments, try exposing a web API on the source that returns the document, and then use an integration object on the target environment to call that endpoint. You can create a service account on the source environment and generate an API key for it, then use that API key in the integration (via an HTTP connected system) to authenticate. You can run a process model or call the integration from a SAIL form when you want to pull the document over.

    If you want to need to initiate the transfer from the source environment rather than pull it from the target environment, just reverse this design and put the wep API to receive a document on the target and the integration to send the document on the source.

  • 0
    Certified Senior Developer
    in reply to Jacob Rank

    Is it possible to send 2 different documents using this? If yes, how?