Upload a document using the REST API
search cancel

Upload a document using the REST API


Article ID: 261324


Updated On:


Clarity PPM On Premise Clarity PPM SaaS


Is it possible to upload a document using the Clarity REST API?


Clarity 16.0.2


Here is the usage via Postman. A few things are important:
  1. resourceName is the API Attribute Id of the Object (for Project it is projects and for Idea it is ideas). resourceId is the Instance Id. In the below example, it's one of the Project Id. Resource Type is fixed and it is ODF.
  2. Similarly, the attributeName is the API Attribute Id  of the attachment attribute which you have defined for an Object 
  3. In the Authorization tab, select Auth type as Basic and provide the necessary credentials
  4. For the file attribute, select the type as File. You will see a select button enabled on the right-hand side so that you can select the required file for upload
  5. Now you should be good to Click the Send button (The response would be 200 OK). Also check on the Clarity MUX and the file uploaded would be visible.
You can also automate this approach. On the right-hand side of the Postman editor, you can notice the Code button. Click on it and a curl script should be visible:
e.g.: The Base 64 encoded password would be different. You make a list of curl commands in a single file with the input for different resourceId and resourceName and run them as a curl command as well:

curl --location --request POST 'http://localhost/ppm/rest/v1/virtual/attachments' \
--header 'Authorization: Basic YWRtaW46aW50ZXJPUEAxMjM=' \
--form 'resourceId="5082210"' \
--form 'resourceName="projects"' \
--form 'resourceType="ODF"' \
--form 'attributeName="p_multiAttach"' \
--form 'file=@"/C:/Viswanath/Clarity/Test - Copy (4).xml"'

Additional Information



It is not possible to migrate documents with existing attachments without downloading them first.

Suggested workaround by Engineering on using the REST API to upload a document: