Solved

​Uploading Attachments via Rest API in IFS Cloud

  • 31 January 2024
  • 4 replies
  • 247 views

Badge +3

Hello, I am trying to upload an attachment (to a customer order in this example) in IFS Cloud via the Rest API. I am following the documentation found in this post: https://community.ifs.com/technology%2Dinfrastructure%2Dcloud%2Dintegration%2Ddev%2Dtools%2D50/upload%2Ddocument%2Dvia%2Dcreateandimportdocument%2Dsvc%2Dedmfileset%2D6284?postid=23329#post23329

 

I understand the process has 4 parts:

  1. Create the document
  2. Attach the document to an object (Customer Order in this case)
  3. Ask for an upload URL for the attachment
  4. Upload the attachment. 

I have successfully performed items 1-3 via postman, and received my upload URL: 

https://[MY IFS SERVER]/int/ifsapplications/projection/v1/CreateAndImportDocument.svc/EdmFileSet(DocClass='AGREEMENT',DocNo='1551348',DocSheet='1',DocRev='A1',DocType='ORIGINAL',FileNo=1)/FileData

When i try to upload my document, i receive this response:

{
    "error": {
        "code": "ODATA_PROVIDER_ERROR",
        "message": "An internal server error occurred. Contact administrator.",
        "details": [
            {
                "code": "PROJECTION_IMPL_EXCEPTION",
                "message": "Error when writing the file: Error while uploading the file. Detail: null"
            }
        ]
    }
}

I have tried in both postman and python via requests module and i receive the same error. This is what my postman request looks like: 
 

Any idea what i am doing wrong here? 

icon

Best answer by dsj 31 January 2024, 22:25

View original

4 replies

Userlevel 7
Badge +20

Hi @mdezzi 

Set the X-IFS-Content-Disposition header value as filename=<BASE_64_Encoded_file_name> and try.

 

Hope it helps!

Damith

Userlevel 4
Badge +9

Hi,

 

another note from the documentation of Mathias (in addition to what already Damith said): header parameter ‘If-Match’ must be set to ‘ETag here’.

 

Best regards, Heinz

Badge +3

@dsj fantastic, thank you. I had the encoded filename, but not the “filename=” tag.

 

@heibde i saw that, but i’m not entirely sure how to get the etag, its not supplied as a response payload in any of the first 3 steps. I am using a * as a wildcard match, which seems to work. 

Userlevel 7
Badge +20

@dsj fantastic, thank you. I had the encoded filename, but not the “filename=” tag.

 

@heibde i saw that, but i’m not entirely sure how to get the etag, its not supplied as a response payload in any of the first 3 steps. I am using a * as a wildcard match, which seems to work. 

 

Me too. I also wasn’t unsure how to get the Etag and used If-Match = * worked for me too!

(Later referred to the documentation and bit surprised by that 😁)

Reply