Skip to main content
Question

Upload document via CreateAndImportDocument.svc/EdmFileSet from Logic App Custom Connector

  • January 23, 2023
  • 2 replies
  • 293 views

Alexander Heinze
Superhero (Employee)
Forum|alt.badge.img+23

Based on an OpenAPI v2 definition of the CreateAndImportDocument API I have created a custom connector in Azure Logic Apps. The creation of the document works fine, but I fail on the upload (i.e. patch) step.

The raw input shows

    "body": {
        "FileData":"......." 

...however the API seems to only expect the raw file as body. Have changed the swagger definition of the filedata parameter to file, but still my input looks something like this:

    "body": {

        "$content-type": "multipart/form-data",

        "$multipart": [

            {

                "body": {

                    "$content-type": "image/jpeg",

                    "$content": "..............."

                },

                "headers": {

                    "Content-Disposition": "form-data; name=\"FileData\""

                }

            }

        ]

    }

IFS Cloud response:

      {
        "code": "UNSUPPORTED_CONTENT_TYPE",
        "message": "The content type 'multipart/form-data;boundary=\"d2956e58-622f-4b26-bbdf-55b61f018754\"' is not supported."
      }

I didn’t find a different way of sending my file content as request body. Anyone any idea how to solve this?

2 replies

Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2891 replies
  • January 30, 2023

Hi Alexander,

I don't have any experience with Azure Logic Apps, so I cannot give you a recipe on how to upload a file there.

I could be wrong but I think the we are not uploading files using the multipart/form-data content type. I have an old bash script (see below) that uses curl to upload a file and the actual upload (patch request) is quite small.


echo Creating document...

ROOTURL=https://SERVER:PORT
DOCCLASS=200

# AUTH is a Base64-encoded version of username:password.
# Below the username and password is jackie:jackie

AUTH=amFja2llOmphY2tpZQ==

docNo=$(curl -s -k --location --request POST $ROOTURL'/int/ifsapplications/projection/v1/CreateAndImportDocument.svc/CreateDocument' \
 --header 'Authorization: Basic '$AUTH \
 --header 'Content-Type: application/json' \
 --data-raw '{"DocClass" : "'$DOCCLASS'", "DocNo" : null, "DocSheet" : null, "DocRev" : null, "Title" : " Test Document", "BookingList" : null, "Id1" : null, "Id2" : null , "CreateFileRef" : "YES"}' | grep -Po '"DocNo":"[0-9]+"' | grep -Po '[0-9]+')

echo Document $docNo created. Uploading file...

echo Root $ROOTURL

curl -s -k --location --request PATCH $ROOTURL'/int/ifsapplications/projection/v1/CreateAndImportDocument.svc/EdmFileSet(DocClass='\'''$DOCCLASS''\'',DocNo='\'''$docNo''\'',DocSheet='\''1'\'',DocRev='\''A1'\'',DocType='\''ORIGINAL'\'',FileNo=1)/FileData' \
 --header 'Authorization: Basic '$AUTH \
 --header 'Content-Type: application/octet-stream' \
 --header 'If-Match: ETag here' \
 --header 'X-IFS-Content-Disposition: filename=Z3J1bXB5Y2F0LmpwZw==' \
 --data-binary '@/C:/tmp/grumpycat.jpg'

echo All done.

echo Download URL: $ROOTURL'/int/ifsapplications/projection/v1/CreateAndImportDocument.svc/EdmFileSet(DocClass='\'''$DOCCLASS''\'',DocNo='\'''$docNo''\'',DocSheet='\''1'\'',DocRev='\''A1'\'',DocType='\''ORIGINAL'\'',FileNo=1)/FileData'

Perhaps that script can nudge you in the right direction.
 


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2891 replies
  • January 30, 2023

Also, when in doubt, always have a look in Chrome's Developer Tools, under Network, how the requests should look like. Then you of course need to "translate" what's there into the language or tool you use.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings