Skip to main content
Solved

Upload document via CreateAndImportDocument.svc/EdmFileSet


Forum|alt.badge.img+9
  • Hero (Customer)
  • 59 replies

Hi,

I’m trying to upload a file via an Aurena REST API. However I can’t figure out what I should use as in the FileData. I’m getting a message “Invalid value for property 'FileData'”. I’ve tried several encoding methods but I have had no luck yet. 

Image of the input and error.

 

Best answer by dhlelk

Hi @Jur,

I see that DocNo is not the same on your requests.
Further, are you able to check-in the same file using the same user and document class from the Application?

However, I have attached my Postman collection herewith. You could import and use that as a template for testing.

Please make sure that you change the authorization credentials and baseUrl variable.

 

 

Cheers !
Dhananjaya.

View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

21 replies

dhlelk
Superhero
Forum|alt.badge.img+15
  • Superhero
  • 200 replies
  • February 4, 2021

Hi @Jur,

It seems that you are sending an empty string "" for FileData.
It should be a Base64 encoded string.

Could you try the below?
"FileData": "dGVzdA=="

Cheers !
Dhananjaya.


Forum|alt.badge.img+9
  • Author
  • Hero (Customer)
  • 59 replies
  • February 4, 2021

@dhlelk thanks for the very quick response! I’ve actually been trying a bunch of encoding methods but none seem to work. With the suggested string I get the same error.

Error message.

 


Forum|alt.badge.img+9
  • Author
  • Hero (Customer)
  • 59 replies
  • February 23, 2021

Has anyone had any luck with this API?


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2824 replies
  • March 1, 2021

Hi all. Until IFS Cloud is released, we have kept the documentation about this API in a separate document. It is attached here.

 


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2824 replies
  • March 1, 2021
dhlelk wrote:

It seems that you are sending an empty string "" for FileData.
It should be a Base64 encoded string.

Could you try the below?
"FileData": "dGVzdA=="

No, FileData is a stream of bytes. The filename, set in that header, should be Base64-encoded though (and do NOT include the full path, it should only contain the filename, like “test.txt”).

 


Forum|alt.badge.img+9
  • Author
  • Hero (Customer)
  • 59 replies
  • March 1, 2021

Hi @Mathias Dahl,

Thank you for your response and the attached document. When I try to follow your document I get an error when I try to upload the file: 

 

Is there something I’m doing wrong?


Forum|alt.badge.img+3
  • Do Gooder (Partner)
  • 7 replies
  • March 1, 2021

I’ve got this working by following the same documentation that Mathias provided. Not on a Cloud instance though. IFS10UPD9


dhlelk
Superhero
Forum|alt.badge.img+15
  • Superhero
  • 200 replies
  • March 1, 2021
Jur wrote:

Hi @Mathias Dahl,

Thank you for your response and the attached document. When I try to follow your document I get an error when I try to upload the file: 

 

Is there something I’m doing wrong?

Hi @Jur,

Try changing the Content-Type to application/octet-stream

Cheers !
Dhananjaya.


Forum|alt.badge.img+9
  • Author
  • Hero (Customer)
  • 59 replies
  • March 1, 2021

@NovAlbinL, that good to hear! We are in UPD8. @Mathias Dahl , could that make a difference?

 

@dhlelk, thanks for the comment. No luck with ‘application/octet-stream’. Still get the same error. 

 


dhlelk
Superhero
Forum|alt.badge.img+15
  • Superhero
  • 200 replies
  • March 1, 2021

Hi @Jur,


For CreateAndImportDocument.svc/EdmFileSet to work there are some important points which you need to note,

1. The document should be created by /CreateDocument endpoint with, "CreateFileRef": "YES"

2. Invoke the /GetDocumentUrl to get the URL for file upload.

3. The above would return a value like, "/int/ifsapplications/projection/v1/CreateAndImportDocument.svc/EdmFileSet(DocClass='100',DocNo='1000010',DocSheet='1',DocRev='A1',DocType='ORIGINAL',FileNo=1)/FileData"

4. Prepend the <host>:<port> to the value returned above to be used as the request URL for /EdmFileSet endpoint.

5. /EdmFileSet endpoint should be invoked using the PATCH method.

6. /EdmFileSet endpoint only support first time/fresh check in.

7. /EdmFileSet endpoint cannot be used to edit and check in the document again through this web service.

8. /EdmFileSet endpoint header should contain the below,
Content-Type:application/octet-stream
If-Match:ETag here
X-IFS-Content-Disposition:filename=<filename.extension_AS_A_BASE64_ENCODED_STRING>

9. No parameters for /EdmFileSet endpoint.

10. If the file is successfully uploaded then the response is none.

11. If you try to invoke the same request for /EdmFileSet endpoint again for the 2nd time, you will get an ODATA_PROVIDER_ERROR since you have already uploaded the document and only first time/fresh check in is supported.


Cheers !
Dhananjaya.


Forum|alt.badge.img+9
  • Author
  • Hero (Customer)
  • 59 replies
  • March 1, 2021

@dhlelk thanks you for the detailed explanation. However, I still get the same error when following your instruction. 

1. Create Document Revision
2. Retrieve upload URL.
3. Using URL from the previous step to upload. I’ve also tried with ‘ETag here’.
​​​​​

Do you spot any mistakes I’m making? Thank you.


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2824 replies
  • March 1, 2021

Perhaps this is a stupid question, but have you added TXT files to the basic data in EDM Basic / File Types?

 


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2824 replies
  • March 1, 2021
Jur wrote:

@NovAlbinL, that good to hear! We are in UPD8. @Mathias Dahl , could that make a difference?

No, the API is the same. I think we added better error reporting in a later update though such that you can actually understand the underlying problem, but the rest of the code is the same.

 


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2824 replies
  • March 1, 2021

FYI, when this API was added we did not have a proper place to keep the documentation. Hence the Word document that I attached a PDF version of above. In IFS Cloud that documentation will be part of the official/proper API documentation that we generate for all the available REST APIs.


Forum|alt.badge.img+9
  • Author
  • Hero (Customer)
  • 59 replies
  • March 1, 2021
Mathias Dahl wrote:

Perhaps this is a stupid question, but have you added TXT files to the basic data in EDM Basic / File Types?

 

Not a stupid question :relaxed: . I have a file type TEXTFILE with the extension TXT in the Document File Types defined. Could there be any other setup I'm missing? Thanks for helping out.

 

@NovAlbinL, would you be so kind to share the one that is working for you?


dhlelk
Superhero
Forum|alt.badge.img+15
  • Superhero
  • 200 replies
  • Answer
  • March 2, 2021

Hi @Jur,

I see that DocNo is not the same on your requests.
Further, are you able to check-in the same file using the same user and document class from the Application?

However, I have attached my Postman collection herewith. You could import and use that as a template for testing.

Please make sure that you change the authorization credentials and baseUrl variable.

 

 

Cheers !
Dhananjaya.


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2824 replies
  • March 2, 2021

Hi,

To show how simple (well...) it can be to use this API to upload files I wrote a small script to upload a document using this API some time back. If you have Git Bash (or Bash packaged in some other way) you can use the attached script to test the API.

Remove the txt extension to run it then run it, like this:

bash $ . createandimportdocuments_community_edition.sh

The script requires Curl as well, for the actual upload. Also, please note the file grumpycat.jpg that needs to exist in c:\tmp. And, of course, the document class 200 need to exist and you need to have added JPG files to the basic data in Docman.

Read the comments in the script and make sure you understand the script before you run it.

Enjoy!

/Mathias

 


Forum|alt.badge.img+9
  • Author
  • Hero (Customer)
  • 59 replies
  • March 2, 2021

@dhlelk Thanks you so much! This worked for me. I'm switching to Postman from now on.

@Mathias Dahl Thank you for the script. It doesn't actually upload the file, but it does amend the filename. I assume this has something to do with my computer.

 

Thank you both very much for the help! This really helps me a lot.


Mathias Dahl
Superhero (Employee)
Forum|alt.badge.img+32
  • Superhero (Employee)
  • 2824 replies
  • March 2, 2021
Jur wrote:

@dhlelk Thanks you so much! This worked for me. I'm switching to Postman from now on.

 

 

Great! Any idea what you did differently?

 

Jur wrote:

@Mathias Dahl Thank you for the script. It doesn't actually upload the file, but it does amend the filename. I assume this has something to do with my computer.

Assuming you actually have Bash, is there an error? Again, the class, filename etc. must be changed according to your setup.

 

 

 


dhlelk
Superhero
Forum|alt.badge.img+15
  • Superhero
  • 200 replies
  • March 3, 2021

 Hi @Jur,

Jur wrote:

@dhlelk Thanks you so much! This worked for me. I'm switching to Postman from now on.

You are welcome and I'm happy to help 😊
Further, it would be great to know what actually went wrong when you tried the same.

Cheers !
Dhananjaya.


Forum|alt.badge.img+9
  • Author
  • Hero (Customer)
  • 59 replies
  • March 5, 2021

@Mathias Dahl & @dhlelk, I’ve tried to find differences on multiple occasions but I just couldn’t find any. But due to the fact the script of @Mathias Dahl didn’t work either, I suspect it has to do with some security policies on my computer. I suggest everyone to just use Postman. :grin:


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