Goran
Visitor.
278 views

ServiceAPI upload file and associate with an existing record

Jump to solution

I know it is possible to create a record and upload a file in a single ServiceAPI call PostFileWithRequest(), however, I would like to know if it’s possible to first upload a file using ServiceAPI and then associate it with an existing record? I found the blog with the section “Upload a file and create a new revision” where this exact requirement is covered, but there is a line of code I just can’t figure out:

var fileResponse = client.UploadFile(fi, System.Web.MimeMapping.GetMimeMapping(fi.Name));

The class TrimClient doesn’t have the method called “UploadFile” so I’m wondering how this “client” object gets instantiated? I have a feeling I am missing something obvious, so I apologize in advance.

Thanks in advance.

0 Likes
1 Solution

Accepted Solutions
Goran
Visitor.

Re: ServiceAPI upload file and associate with an existing record

Jump to solution

Although I’m still not clear about the line of code mentioned in my opening post, I think I solved the original problem. The requirement was to upload a file and associate it with an already existing record. I am able to do it by using the API PostFileWithRequest(). The trick is when creating the “Record” object to set the property “Uri” to the URI of the existing record. If the Record Type is setup to accept multiple revisions, this approach should work. So simple, yet it took me a day to figure it out. Hopefully it may help someone else from this community.

0 Likes
1 Reply
Goran
Visitor.

Re: ServiceAPI upload file and associate with an existing record

Jump to solution

Although I’m still not clear about the line of code mentioned in my opening post, I think I solved the original problem. The requirement was to upload a file and associate it with an already existing record. I am able to do it by using the API PostFileWithRequest(). The trick is when creating the “Record” object to set the property “Uri” to the URI of the existing record. If the Record Type is setup to accept multiple revisions, this approach should work. So simple, yet it took me a day to figure it out. Hopefully it may help someone else from this community.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.