How to send multiples of same param name with RestClient
I've discovered what I believe is a shortcoming of the RestClient drop-in. If you're POSTing to a service which responds to multipart-form-data requests, then they may expect you to send multiples, for instance in the equivalent GET, how would you manage something like
http://restservice/api/endpoint?input=firstOne&input=secondOne&input=thirdOne?
In my case I'm writing to a service that is expecting multipart form data. I know that RestClient.Post() can take an optional multipart args param, but it, like the params, is an Assoc, so if you have an assoc with a key input, there can be only one.
I know more modern REST APIs would expect input to be passed as a JSON array in this example, i.e. ?input=['firstOne','secondOne','thirdOne'] but that is not an option in this case.
In the past, we managed this using apache http client library, which allowed adding multipart entities for each of the multiples. We moved to RestClient so that we would let OpenText Content Server drive trusted certificates and such.
-Hugh Ferguson
Answers
-
Am I mistaking this or is this any closer to sending File information using multipart as per the RFC so long as you create the boundary correctly shouldn't a webserver accept it?
In the Creation of a Document/Version we usually supply a contorted version of a multipart but my guess is the receiving OT code is looking for a multipart that says body, name,file, and so on… so they are already processing that.
an example File adding multipart
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 -
I understand what multipart is all about, I'm just trying to understand how you send such a request using OpenText's RestClient where you are reusing the same name. When Content Server receives such data, you see it translated to input = elementN and input_list = {element1, element2,…elementN} but there doesn't seem to be a way to send such a thing using the REST client, especially because any POST parameters are expected to be uniquely named the delivery mechanism being an Assoc.
0 -
I think what you mean is a typical RH mechanism if I have a form element called node and I repeat node in my form the record it receives in builder one can see node and then node_list.I think you can look at the code that does that my memory says it is part of the prototype mechanism
according to this it looks like what you are saying holds that it can only be named once
Have you tried something like faking lit and calling it
input_list=['firstOne','secondOne','thirdOne']
I belive the RESTClient in oscript can be seen in the OTDS ospace perhaps you could find an example looking at that code? or maybe looking at how WR uses the RESTClient…
https://knowledge.opentext.com/knowledge/llisapi.dll?func=ll&objId=78337965&objAction=browse
0 -
I looked into this before. The REST client is a full-fledged Oscript drop-in. Translation: No source provided. I also tried passing the list of same-name params by setting the param to a list type - crashes RestClient call (no error, just returns unspecified error). I also tried passing the same param as additional <param name>_list with the values as a list. That too crashed. I checked the Oscript documentation, and it doesn't offer a lot of additional details. I'm looking at the WR tag guide…I can't seem to find anything on REST Client, but under the hood I know from before it uses the same drop-in.
I posted here in the vain hope that someone from OT development might see this as they have access to the source code repo for RestClient. I want to know if this is a use case they hadn't anticipated, or if there really is a trick to this.
-Hugh
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 150 General Questions
- 148 Thrust Services
- 57 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories