How to use /v2/nodes/{id}/versions
I am trying to figure out how to use above method trying to connect to OpenText. We intend to upload a new version of an already existing file.
Checking out this link under "Add version":
It is stated that "If your REST client does not support file uploads, you will need to specify additional information in the body" one should use following in the body:
file=<full pathname>; file_content_type=<mime type>;file_filename=<filename>
I assume above is what I should use since we don't support file uploads. Now, it doesn't make sense since it should be enough specifying the ID for the target. But semantically that is what is specified.
As a starter, only "file" is specified for the description of the method in the API specification/swagger. So feels a bit strange to use parameters not specified. Anyhow…
I do understand that I should use body={} format. But please correct me if I am wrong.
Shortly: How should I use this method? An example would be great!
Answers
-
If you are a new programmer it is kinda hard to understand however the trick is to understand POST in a webserver
POST is a name/ value pair operation so, in this case, we create a fake "body","name","filename" etc so when you submit the request the whole payload goes in as name/value pairs including the file that you post in that call. The HTML body is not the "body" OpenText talks about.
in this reply if I am not mistaken I have shown a Postman payload as well as some ways to do this once you understand it in Postman convert it into a language of your choice
https://forums.opentext.com/forums/developer/discussion/312086/does-create-document-in-v2-nodes-api-support-multipart-form-data#latest
Uploading the first and the subsequent version is pretty much the same except for the rest api involved.
Another trick we all use is the SMARTUI of OpenText, which is a client that converses through the server using REST so you can observe the payload it would be similar to what your Postman experiment tells you
OT allows you to send the file only to the web server or application server of OTCS. They don't support picking up a file in a CIFS/SMB share or encoding it with base64.
another recent example with POSTMAN
https://support.opentext.com/community?id=community_question&sys_id=b7ad2bde97c9c21034127e400153af0f&view_source=searchResult
0 -
Thanks' for the response!
Does below seem to be correct for the "body" part? I do understand it is not HTML Body and we are using this "standard" for other methods.
body={"file":"Content of file","file_content_type":"text/plain","file_filename":"ws_user.txt"}
URL: https://<domain>/LiveLink/ContentServer/basic/v2/nodes/49434995/versions
Where 49434995 is the id of the actual file to add a new version to. file_filename is the same name as the target file is having.
Unfortunately we cannot use Postman in my organization. Otherwise I would be all over it.
UPDATE:
The response using above is this:
{"error":"Error: File could not be found within the upload directory.","request_id":"08ba58c5-c928-4ce3-a38f-05a73a08700d"}
0 -
Still same result if I am using multipart.
Content-Type: multipart/form-data;boundary=--f8n51w2QYCsvNftihodgfJ
Sent body:
----f8n51w2QYCsvNftihodgfJ
Content-Disposition: form-data; name="file"Content of file
----f8n51w2QYCsvNftihodgfJ
Content-Disposition: form-data; name="file_content_type"text/plain"
----f8n51w2QYCsvNftihodgfJ
Content-Disposition: form-data; name="file_filename"ws_user.txt
----f8n51w2QYCsvNftihodgfJ--Response:
{"error":"Error: File could not be found within the upload directory.","request_id":"a5301aa5-efa1-4aa4-ace2-6e5a9d8a653f"}
0 -
I am seeing this in my network tools/fiidler
POST /otcs/cs.exe/api/v1/nodes HTTP/1.1
Host: myserver:8080
otdsticket: OTDSSSOAahBQlNza0xkQ3Bycm1sbHlyOUx6LVUzUE5mV0NmeGdBTTlXWlhjVExzX3ZKRkNrZm5BUmRBWGk2MERZNHlrNXBIYWxuY2lyajVTXy05T3pLa3ZiZzdJblJsdXNweFpWNi1hUnE1c2Uwak9EakU3UmtfUWg1ZjdZekNkVjRtQmZOUHl6Y0ZocGkzLTJROTg4cHE1dURvWnpFc09NU1daUmtKLWVSWWJkWjlBMHRnWWlzNkRYWTBPM1o3UXRzcmhzelpiZUN6WkdmazBReDVOWWxBdlFYMVU2ZFRHaEhQVUJQYjQ4eXhzNkE1VlhfQ2J0Zmp1cF9fZll4U3N2M1BFZHRXMmdQYlZfX2FqWVJxMXNZQ0ZldVRBWkpGamtSMXNzNlJjV2xKMm90d0F0Tk1aN3FBQzNtU1hUa3NPdHR1WEpPNTUtQ1BRYS1zbVpUdThyemFuVFVhSFFUb2RUWFBwUmNwRV83Zjllcl95Y0dUV2tad2szQ05UZzZrZXFrT1doZ0w4eEw5RDdMdHluc0ZGU09HZWtoTm93LVMzWXVyemdzQWRFU2o5ZmMqAE4ASgAUPYQ13uu1FoVqEjENgXatog6tg24AEGj2sghHvv6SqFhrQiABNSEAIFStWWYbeg-32lSq44Pjs2Jwchqubr8CW7Z-x7fWjmiLAAA*
Content-Length: 523
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="type"144
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="parent_id"2000
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="name"Filename for CS
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="///mycifsshare/c$/temp/AIMSuiteRESTlog4net.log"
Content-Type: <Content-Type header here>(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--Your payload looks different do you want a simple html file that does this?
0 -
adding a version is very similar to a creating a node and a version for the first time, sanitized code ,The form data element called body is where you put anything extra like a description
POST /otcs/cs.exe/api/v2/nodes/209636/versions HTTP/1.1
Host: myserver:8080
otdsticket: *OTDSSSO*AaxBQlRtZQ4Sb2n0ib1Bknpzq7533YsnD83SwAA
Content-Length: 419
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="body"
{"external_modify_date":"2024-10-18T14:57:47.990Z"}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="/C:/Users/appuq/OneDrive/Desktop/Screenshots.docx"
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--0 -
Ok, I am breaking it up in two sections and then we can see if I can post.
How does this comply with this part?:
It is stated that "If your REST client does not support file uploads, you will need to specify additional information in the body" one should use following in the body:
file=<full pathname>; file_content_type=<mime type>;file_filename=<filename>
Should I define those as an "associative array" as you have done with external_modified_date?
0 -
Ok, that post was saved. Trying the second part:
I actually tried what you specified before (except the body section). It work a couple of times but then it stopped working. Seems to be some intermittent errors. We can see in our integration gateway that the data we are sending when it was working and when it was not working is exactly the same but still OpenText sometimes returns success and sometimes error.
I will try it again with this format shortly.0 -
you can see I am using OTDSTicket OTDSTicket gets exchanged internally for an OTCSticket.If you do rapid-fire succession against OTCS clusters unless the OTCS servers are set correctly the OTCS server will sometimes balk at an OTCSticket from another server. By trial and error, I have found OTDStickets having much more luck :)
file=<full pathname>; file_content_type=<mime type>;file_filename=<filename>
Should I define those as an "associative array" as you have done with external_modified_date?
You are on your own there I doubt from a JSON string how a server can know it is a file, in actual HTTP protocol to send a file either you need to stream it or send a file, I think we are sending the file by making it into a multi part
0 -
You might try to get an official answer from OT on that and most likely they will say to use their professional services but if you try to send a file like that
{
"file": "/C:/appu.docx", (I tried various permutations/combinations:))
"file_content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"file_filename": "appu"
}{
"error": "Error: File could not be found within the upload directory.",
"request_id": "f93aa620-1617-4007-b03e-f14244b26bda"
}I am a content server programmer, so I could debug it, but I have no time. I guess that the CS server has an upload directory set, and if you put the file in the server it will change to something like this. A long time ago, OT would allow files to be accessible on the server. It was probably removed as it could be a security hazard, so maybe the low-level code may be geared to look for a POST-ed file.
{
"error": "An illegal attempt was made to upload a document",
"request_id": "c4f29be5-6f9a-4ffe-bfb6-50172d5188e5"
}BTW code along the lines posted above is what I used in an IBM Tivoli integration not long ago :)
0 -
Yeah, I know. Since we prefer getting a solution without professional service I posted here as a starter. But have asked the OT side of our business to post a ticket as well. But we already know the answer…
This I usually get when the format is incorrect:
An illegal attempt was made to upload a document
But as I mentioned, I will have a go at the format specified above again in a while. I.e. next week.
Thanks' for the input so far.
0
Categories
- All Categories
- 122 Developer Announcements
- 53 Articles
- 151 General Questions
- 146 Thrust Services
- 56 OpenText Hackathon
- 35 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 917 Cloud Fax and Notifications
- 84 Digital Asset Management
- 9.4K Documentum
- 31 eDOCS
- 179 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 9 XM Fax
- Follow Categories