Add file
OVERVIEW
This API method supports creation of a new file given the parent folderid. The parent folderid can be obtained by using the “folders list” API endpoint.
Request
POST /api/1/files/content
The Media type should be set to multipart/form-data
Query Parameters
Parameter Name | Value | Description |
---|---|---|
parentfolderid | Int | The ID for the folder in question |
sourceclient={sourceclient} (optional)
|
string | A name which uniquely identifies each client. This name is used to register the changes made by each client application. When the client calls the changes API to determine the changes on the server, this value helps them to determine if the change belonged to them. This can help them to filter and ignore their changes. |
Form Parameters
Parameter Name | Value | Description |
---|---|---|
filename | String | Name of the newly created file |
file | Binary file data | Make sure that the parameter name is called file and the value for it is the file to be uploaded |
notification | Int | Optional parameter called "notification" which is used for email "notification" preference. 1 = Respect user preference 2 = Force email notification 3 = Suppress all notifications (Default if this parameter is not supplied) |
The file should be added as multipart form data. Please note that the parameters are case sensitive.
Below are some optional parameters that can be used to manage a two way sync with an external DMS system like worksite. These parameters are stored with the document itself and can be referenced in get file API call.
Parameter Name | Value | Description |
---|---|---|
dmsparentfolderid | string | ID of the parent folder of the document as available in the external DMS system |
dmsdatabasename | string | The name of the database from where the document was obtained. This is to store the exact location of the document in the external DMS system |
dmsdocid | string | The document id of the document in the external DMS system |
dmsversion | string | the version of the document in the external DMS system |
dmseditdate | string | The date when the document was edited in the DMS system. The format for date is yyyy-MM-dd HH:mm:ss |
Please note that in order to view the DMS version information in the files module of a site, you will need to enable the "Show WS versions/drafts" configuration from the site admin -> files module of a site.
Response
If successful this method returns the details of file resource in the response body.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<file>
<fileid>855</fileid>
</file>
Parameter Name | Value | Description |
fileId | Int | The ID for the newly created file in question |
Hi
We are trying to integrate HighQ with our Dynamics CRM. We are facing issues with getting the OAuth Code without involving the user. We want to add a file to HighQ using the API without the user login.
We dont want a user to log in.
Is that not possible?
Morgan Newman I tried both text and File. Same error
Celal Yilmaz Good morning, did you try file instead of text and select the file from your filesystem?
This might help narrow down where the problem is.
Im trying to create a file trough Postman, but im getting error 403:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
403
Invalid fileid =content
I have tried with having the file as type file and also tried with Base64 and binary data as text but same error.
any suggestions?
Andrew Quinn Thanks so much for your help, this saved me hours of tinkering and it works a charm!
Morgan Newman, firstly you need to load the file as text, not binary(*), then I've annotated a screenshot of the PA "Invoke a web service" properties to show what's needed.
* When loading the file as Binary, PA sends:
Byte []
in the request body. Basically ByteArray.toString() I would guess. And as for base64, I don't think this endpoint accepts base64 encoded content, at least nothing in a documentation (cough) would seem to suggest otherwise.
Hope this helps,
Andrew
Hi All, I am wondering if anyone has had any luck adding files with powerautomate desktop. I am trying and cannot seem to get the request to work correctly, though postman requests work fine, etc. I am using invoke web service, multipart/form-data as content type then the following (tinkered with this a lot but I am obv missing something:
{
"$multipart": [
{
"headers": {
"Content-Disposition": "form-data; filename=\"test4\""
},
"body": %ProjectPathPDF%
}
]
}
I've also tried putting in binary data and base 64 blob. I am getting 400 - Request resource or xml is not valid back.
What am I doing wrong here?
Thanks for your time!
Hi everyone, I am concerned when I upload a file, whether this API already has a virus scanning mechanism for the file or not. Thanks
Akshay More -> Unfortuantely not, I do not believe we expose this functionality via the API.
Enhancement request CC Imran Aziz ?
is it possible to upload a zip file through API and highq will unzip it ?
@Peter Simpson: It worked for me. I must have been over complicating things! Thank you.
Peter Simpson Thank you. I have been away for a while (unexpected). I am about to try this out.
Petert Tuffin
var client = new RestClient("https://supportteam.highq.com/supportuat/api/1/files/content?parentfolderid=10688");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer REDACTED");
request.AddFile("file", "/path/to/file");
request.AddParameter("filename", "test");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Peter Simpson Are you able to export that Postman code, or, even better, get Postman to generate a RestSharp example. That has worked in the past very well.
Peter Tuffin, it's likely you are not supplying a "User-Agent" string in the POST header.
Petert Tuffin
Please raise a ticket with support, including the uri, method, headers and body of your request and we'll try and work out what's going on.
-------------------------------------------------------------------------
Here are the logs from a successful POSTMAN call:
POST /supportuat/api/1/files/content?parentfolderid=10688 HTTP/1.1
Accept: application/json
Authorization: Bearer REDACTED
User-Agent: PostmanRuntime/7.26.8
Postman-Token: 4c6f8ac4-3967-484c-a604-32ac0ef087eb
Host: supportteam.highq.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------------------------207523876272597285876618
Cookie: ROUTEID=.app15b456
Content-Length: 75894
----------------------------207523876272597285876618
Content-Disposition: form-data; name="file"; filename="kira.csv"
----------------------------207523876272597285876618
Content-Disposition: form-data; name="filename"
test
----------------------------207523876272597285876618--
HTTP/1.1 201 Created
Date: Thu, 08 Apr 2021 17:28:21 GMT
Server: Apache
Cache-Control: no-cache, no-store
Pragma: no-cache
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 2000
X-Ratelimit-Remaining: 1996
X-Ratelimit-Reset: 1617903298
X-Ratelimit-Relative-Reset: 398
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 18
Keep-Alive: timeout=10, max=500
Connection: Keep-Alive
{"fileid":"52310"}
The reason I am asking for more sample code is that, try as I may, I cannot get the API to accept any apparently well-formed POST to upload, as it consistently responds with Unsupported Media Type.
I have been working on and off with the sample solution, but now it turns out that it is not going to work for us, because, for various reasons, our applications do not co-exist nicely with async code. Unfortunately, the sample code uses HttpClient, and has a few async calls. Is there no sample C# code which can be used to upload to HighQ, other than code that uses HttpClient? RestSharp would be the best, but even HttpWebRequest/Response would be OK.
Petert Tuffin Glad to hear you got it sorted!
Weirdly we've had a bit of a speight of this recently, (although nothing has changed at our end, so I guess a lot of people wanted to use 'Upload File' at the same time)....
This python snippet results in the system being unable to correctly 'read' the file as its proper file type (assuming 'TEST.pdf' is the file I have on my computer
....
url = 'https://foo.com/bar/api/1/files/content?parentfolderid=15'
multipart_form_data = { 'file': ('TEST', open('TEST.pdf', 'rb')), 'filename': 'TEST', }
response = requests.post(url, headers=headers,files=multipart_form_data)
....
Whereas this one works as expected:
....
url = 'https://foo.com/bar/api/1/files/content?parentfolderid=15'
multipart_form_data = { 'file': ('TEST.pdf', open('TEST.pdf', 'rb')), 'filename': ''TEST', }
response = requests.post(url, headers=headers,files=multipart_form_data)
....
The reference to the actual file object in our storage and its name as displayed in the frontend are decoupled, so I think its juggling these two different things which usually leads to that phenomenon you are describing.
A rule of thumb is to keep references to the file extension in the file field of the form data... Not sure if that tallies up with what you were doing or not? Would be interested to know!
I have installed and used the sample code in https://collaborate.highq.com/sitepoint/documentHome.action?metaData.siteID=714&metaData.parentFolderID=20848&metaData.documentID=251706. It uploads a text file successfully. It also uploads a .docx file successfully, but the resulting file, when downloaded off the web site UI, is corrupt. I have tried with fileContent.Headers.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", but with the same result - the uploaded .docx file, when subsequently downloaded, is corrupt and Word cannot open it. Can anyone help, please?
Update: I have sorted this out. My code was incorrectly reading the content of the .docx file.
Hi Imran, when I upload a file, highq adds an extension. This means that the file hi.txt will be called hi.txt.txt. How is the extension calculated? How can I preserve extension so that our customers see the same thing in both systems? For example, if the file has an extension highq does not know about?
Maarten Van.duijn ah I see in that case its an issue with using the AddFile API, please raise the issue based on that. It might be an idea to view previous comments on this post, as multiple people had addressed the issues developers have been facing and what they were missing in their request.
Thanks Imran Aziz, I will contact support. I have not been able to upload files to any folder through the API, folders either created through UI or API. Uploading through UI works fine.
Maarten Van.duijn your request seems fine to me, can you please raise this issue with the support team at support@highq.com, so that the technical support team can look into your issue. Just for clarification have you been able to upload files using the API as your above comment did not clear that for me. Just trying to understand if the issue is with creating folders or uploading file.
hi Imran, Maybe the raw message tells something of what I might be doing wrong I sent the folowing to the /content endpoint (very small file to test)
POST https://integrationbeta.highq.com/integrationbeta/api/1/files/content?parentfolderid=36088 HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: multipart/form-data; boundary="----=_Part_75_30753904.1530200894979"
MIME-Version: 1.0
Authorization: Bearer mHNh5QQO_wg0inV6na213yUm9xky8WSM
Content-Length: 571
Host: integrationbeta.highq.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
------=_Part_75_30753904.1530200894979
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: form-data; name="filename"
test
------=_Part_75_30753904.1530200894979
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: form-data; name="notification"
3
------=_Part_75_30753904.1530200894979
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: form-data; name="file"
dGVzdCAxMjIz
------=_Part_75_30753904.1530200894979--
HI Imran thanks for your swift reply. To answer your questions:
1 Using the UI I can add files to my folder.
2. This is both an issue with folders I created through the UI and through the API. The UI tells me I have all permissions (being an admin), the API tells me I have Permission 'UPDATE', see below.
3. I have tried with both accessinherited = 0 and 1.
This is a folder list obtained through the API, I would like to put a file in folder 36088
<folder>
<id>36088</id>
<name>Assembled documents</name>
<permission>UPDATE</permission>
<child>1</child>
<description>General bin to recieve documents that are created by the Berkeley Publisher. Subfolder structure and access management should be discussed.</description>
<parentFolderID>36044</parentFolderID>
<accessInherited>1</accessInherited>
<createddate>25 Jun 2018 14:18</createddate>
<modifieddate>25 Jun 2018 14:18</modifieddate>
<location>Berkeleybridge sandbox</location>
<createdby>
<firstname>Maarten</firstname>
<lastname>Van.duijn</lastname>
<email>maarten.van.duijn@berkeleybridge.nl</email>
<userid>1375</userid>
</createdby>
<modifiedby>
<firstname>Maarten</firstname>
<lastname>Van.duijn</lastname>
<email>maarten.van.duijn@berkeleybridge.nl</email>
<userid>1375</userid>
</modifiedby>
</folder>
Maarten Van.duijn do you get the same error when you try to upload a file to a folder created using the UI? or is this only an issue when you create a folder using the folder API. What permissions does the folder have when you create it using the API? Do you inherit the folder permissions?
Maarten Van.duijn Imran Aziz could you please assist Maarten
I'm testing with SoapUI on the collaboration API, after calling an addfolder function, and recieving a new folder id, I proceed tp call content?parentfolderid=mynewid to add a file in that folder. The response is
<error>
<link>https://integrationbeta.highq.com/integrationbeta/api/1/error/12617906</link>
<ref>403</ref>
<summary>Access denied</summary>
</error>
Is there any step that I skipped here?
Imran Aziz Thanks Imran - yes I realised that soon after I added this comment :)
Giuseppe Carafa do you mean adding a new version to a file then that is available through the Add file version API.
Jamie Yao Imran Aziz - yes I would be looking for same.
Imran Aziz Thanks for the code. It seems working. Is there an option to force override a existing file with the same name?
Jamie Yao please look at this text file the team has provided to resolve your issue with uploading file
Jamie Yao The 403 error generally happens when there is a permissions issue, can you please try and upload that file to the required location using the web interface, if it works in the web interface and you are still getting a 403 error via the API then can you please raise a support ticket . Thanks
I tried with http and got the error message: The remote server returned an error: (403) Forbidden. Would you be able to see if the parameters are correct?
Jamie Yao our team believes that the proxy server on your network does not respond on "https", can you please change the proxy server URL to "http" and try again. Thanks
Jamie Yao wonderful thanks, give us sometime and we will investigate and if required update the demo App.
I use Visual Studio 2015 with update 3.
Jamie Yao this issue might have occurred because of the .net version on your machine, can you please let me know what .net version is installed on your machine and I will ask our team to investigate accordingly. Thanks
I tested with the APITest and got error: The ServicePointManager does not support proxies with the https scheme.
Dan Hunsinger glad to hear that its working now. I am afraid the customisation is very limited, the only thing that can be altered is the column name, which I have now changed to "DMS"
Imran Aziz Thanks. It all works as advertised. Is there any way to customize what shows up in that column? It looks like it just defaults to the version id.
Dan Hunsinger I have made you an internal user, so please try now, the DMS column should appear for you.
Imran Aziz I believe you set up this site for us for development purposes and it looks like I'm an external user. Is there a way I can be an internal user for testing purposes? Thanks.
Dan Hunsinger can you please let me know if you are an internal user or external user of Collaborate ? we are not showing DMS information to external users. If you are an internal user and are still not able to view the DMS information then please raise a support ticket at http://support.highq.com and provide the Collaborate instance and site details, so that we can debug this issue for you. Thanks.
Imran Aziz In the admin section, I have the show WS versions checkbox checked, but the files module it doesn't show the WS column.
Fernando Deleon sorry for the delay in response to your question. I am afraid the OAuth code generation process is the standard OAuth code generation methodology, and there is no alternate way to generate the code. Impersonation is on our roadmap and will be addressed in one of the future release of HighQ API.
Dan Hunsinger Can you please provide a bit more detail when you say nothing shows up? do you not see an additional WS column in the files module of a site ? or the column does show up but it does not have any values ? You can also raise a support ticket and provide specific screen shots as that will help in understanding the issue.
I'm trying to set the optional parameters (dms...) so that the HighQ interface indicates a document is being synced with something. I believe the parameters are being sent correctly because when I view the version history, I can see my data in a line that starts with "WS:". In admin I selected to show the WS versions and drafts but nothing shows up in my file. What am I missing? Thanks.
Thanks Imran Aziz for your response and yes I suspected that was the issue.
So really it comes down with the generation of the code which is then use on https://corrs.highq.com/corrs/api/oauth2/token to generate the access_token that the WS uses.
I see that the generating of this code basically takes your hash username and sends a post to oauthRedirectUrl.action which then redirects to a nominated page which attaches the code as a query string to the nominated redirected page.
Question.. Is there another way of creating this code?
Will impersonation be something that will be available on the next version of Collaborate?
Thanks
Fernando Deleon the author is determined based on OAuth token, your colleagues must be using the OAuth token which you created with your account. Your Colleague needs to generate his own OAuth token using his own Collaborate account, which will then register all API actions with his identity. Our API does not provide any impersonation capabilities at this time, so that you can take actions on behalf of another person.
Hi, Imran Aziz
I generated a token and used the token on my ajax call and am able to add a file via the this API.
Another colleague of mine did the same, however the author of the document was set as me and not my colleague is there a way to change that?
Please make sure that you include the required form parameters to execute this API call otherwise the call will fail with an error.
Comments
55 Comments