Skip to main content
Question

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

  • January 23, 2023
  • 2 replies
  • 320 views

Alexander Heinze
Ultimate Hero (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

1 "body": {
2 "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:

1    "body": {
2
3        "$content-type": "multipart/form-data",
4
5        "$multipart": [
6
7            {
8
9                "body": {
10
11                    "$content-type": "image/jpeg",
12
13                    "$content": "..............."
14
15                },
16
17                "headers": {
18
19                    "Content-Disposition": "form-data; name=\"FileData\""
20
21                }
22
23            }
24
25        ]
26
27    }

IFS Cloud response:

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

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)
  • 2903 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.

1
2echo Creating document...
3
4ROOTURL=https://SERVER:PORT
5DOCCLASS=200
6
7# AUTH is a Base64-encoded version of username:password.
8# Below the username and password is jackie:jackie
9
10AUTH=amFja2llOmphY2tpZQ==
11
12docNo=$(curl -s -k --location --request POST $ROOTURL'/int/ifsapplications/projection/v1/CreateAndImportDocument.svc/CreateDocument' \
13 --header 'Authorization: Basic '$AUTH \
14 --header 'Content-Type: application/json' \
15 --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]+')
16
17echo Document $docNo created. Uploading file...
18
19echo Root $ROOTURL
20
21curl -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' \
22 --header 'Authorization: Basic '$AUTH \
23 --header 'Content-Type: application/octet-stream' \
24 --header 'If-Match: ETag here' \
25 --header 'X-IFS-Content-Disposition: filename=Z3J1bXB5Y2F0LmpwZw==' \
26 --data-binary '@/C:/tmp/grumpycat.jpg'
27
28echo All done.
29
30echo Download URL: $ROOTURL'/int/ifsapplications/projection/v1/CreateAndImportDocument.svc/EdmFileSet(DocClass='\'''$DOCCLASS''\'',DocNo='\'''$docNo''\'',DocSheet='\''1'\'',DocRev='\''A1'\'',DocType='\''ORIGINAL'\'',FileNo=1)/FileData'
31

Perhaps that script can nudge you in the right direction.
 


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2903 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