Skip to main content
Inspiring
Jan 16, 2024 11:46 AM UTC
Question

Several Document upload

I need to store a user id, along side several picture uploads all in a relational database. My solution for storing the pictures would be to save the pictures locally on appian and save the document ids on the database alongside the user id. However, with the way I have it implemented right now it seems I cannot pass in the user id into the body alongside the picture upload as it takes up the entire body. I also cannot attach several pictures for upload. I need a way to be able to pass in the user id and atleast 3 pictures into the body to be saved in the database.

9 replies

harshitb6843
Brainy
Jan 16, 2024 11:48 AM UTC

This doesn't tell us anything about how you have written the code. Do you mind attaching the code snippet so I can understand better why you cannot do things you said you cannot do?

alir5058Author
Inspiring
Jan 16, 2024 11:49 AM UTC

a!localVariables(

  /*Check whether the request body contains a document*/
  local!success: not(isnull(http!request.body)),

  if(
    local!success,

    /*If a document was uploaded, return a successful response*/
    a!httpResponse(
      statusCode: 200,
      headers: {},

      /*Print the document id, name, and extension of the uploaded document*/
      body: concat(
        "Upload Successful: ",
        document(http!request.body, "id"),
        " - ",
        document(http!request.body, "name"),
        ".",
        document(http!request.body, "extension")
      )
    ),

    /*If no document was uploaded, return an error code*/
    a!httpResponse(
      statusCode: 400,
      headers: {},
      body: "400 Document Not Provided"
    )
  )
)

harshitb6843
Brainy
Jan 16, 2024 11:51 AM UTC

For better readability..

stefanhelzle0001
Brainy
Jan 16, 2024 11:50 AM UTC

Seems like you are talking about implementing a web API, correct?

AFAIK, a web API only accepts a single file. The user ID could be passed as a query parameter or a header.

https://docs.appian.com/suite/help/23.4/passing-a-web-api-document-into-a-process-model.html

alir5058Author
Inspiring
Jan 16, 2024 11:51 AM UTC

Is there no way to pass in the user id in the body and the ability to send several pictures aswell?

harshitb6843
Brainy
Jan 16, 2024 11:53 AM UTC

You can construct your request body like this. 

{
  userId: 2,
  documents: todocument({7585,7538})
}