How do i save a XML file that is been sent to my web API

Certified Associate Developer

i have a post  web API  which receives an  XML file   and with this files it triggers a process model. but unfortunately when we get   the  file  we just get the  XML file content. it's like we where getting just the content of the XML and this is a signed  file that should not be modified that's why i hesitate on  just cutting  the text and  paste it in a new file.

my web API

This is  what we are getting in the body of the httprequest

is there a way on turning this into the sent xml file again ?

just  for letting you know the a!httpresponse.formData is empty  because we are not using the xx-www-form-urleenconded

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    If you are looking for document as an attachment to the web API request, use following.

    - While creating a WebAPI use the "Document Upload" template as shown below. While creating the WebAPI object it will ask for a folder to save the document.

    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"
        )
      )
    )

Reply
  • 0
    Certified Lead Developer

    If you are looking for document as an attachment to the web API request, use following.

    - While creating a WebAPI use the "Document Upload" template as shown below. While creating the WebAPI object it will ask for a folder to save the document.

    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"
        )
      )
    )

Children
  • 0
    Certified Associate Developer
    in reply to Abhay Dalsaniya

    yes  i want to upload a  document  and with this document i want to  run a process  and also return another   file  after the process execution ends  but i'm not sending a  straight forward document    i'm sending it as a part of the body   like in the following

     http Request Picture

    the weird part is that  even if  we are sending an xml document we are getting  the xml  content in appian.