Web Api to generate a ZIP of some pdfs and make thw download automatically

Hi! 

How can i make a web Api which its response is a zip of many pdfs.

Regards,

Rebeca

  Discussion posts and replies are publicly visible

Parents
  • Hi Rebeca,

    I think you can achieve this by starting the process on WebAPI (POST Method) call. You can pass PDF information as a parameter to this process and process can get the document IDs of those documents. Then you can use the plugin Add documents to Zip (https://community.appian.com/b/appmarket/posts/add-documents-to-zip?CommentId=192c55d7-a7f2-4d17-9a2f-3b4c300ff2c6) to generate the zip document. All the nodes is this process should be chained so that you can retrieve the Zip document ID in the webAPI and same document can be returned in the response body. Something like below: 

    with(
      a!startProcess(
        processModel: cons!APNSB_TESTAPI_PM,
        processParameters: a!fromJson(
          http!request.body
        ),
        onSuccess: a!httpResponse(
          statusCode: 200,
          
          body: todocument(
            fv!processInfo.pv.testDoc
          )
        ),
        onError: a!httpResponse(
          statusCode: 500,
          headers: {
            a!httpHeader(name: "Content-Type", value: "application/json")
          },
          body: a!toJson(
            {
              error: "There was an error starting the process"
            }
          )
        )
      )
    )
     

    Regards,

    Yogesh 

Reply
  • Hi Rebeca,

    I think you can achieve this by starting the process on WebAPI (POST Method) call. You can pass PDF information as a parameter to this process and process can get the document IDs of those documents. Then you can use the plugin Add documents to Zip (https://community.appian.com/b/appmarket/posts/add-documents-to-zip?CommentId=192c55d7-a7f2-4d17-9a2f-3b4c300ff2c6) to generate the zip document. All the nodes is this process should be chained so that you can retrieve the Zip document ID in the webAPI and same document can be returned in the response body. Something like below: 

    with(
      a!startProcess(
        processModel: cons!APNSB_TESTAPI_PM,
        processParameters: a!fromJson(
          http!request.body
        ),
        onSuccess: a!httpResponse(
          statusCode: 200,
          
          body: todocument(
            fv!processInfo.pv.testDoc
          )
        ),
        onError: a!httpResponse(
          statusCode: 500,
          headers: {
            a!httpHeader(name: "Content-Type", value: "application/json")
          },
          body: a!toJson(
            {
              error: "There was an error starting the process"
            }
          )
        )
      )
    )
     

    Regards,

    Yogesh 

Children