Skip to main content

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.

 

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.


@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.

 


Has anyone had any luck with this API?


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

 


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”).

 


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?


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


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.


@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. 

 


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.


@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.


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

 


@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.

 


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.


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?


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.


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

 


@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.


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

 

 

Great! Any idea what you did differently?

 

@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.

 

 

 


 Hi @Jur,

@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.


@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: