Get files saved as attribute values

Get the contents of the files saved as attribute values.

For security reasons, you need to perform a Login action before making any other public calls to the WorldServer API. The sessionId in the response is your session token. Use this token in all the other calls that you make.

Also, make sure that you have the appropriate user type permissions to perform this API call. To view or update your permissions, in WorldServer, go to Management > User Setup > User Types, and then select your user type.

Prerequisites

To get the files saved as attribute values, you need the internal names of the files. These values were displayed as part of the response when you uploaded the file:A screen shot that highlights the internalName of a file after uploading it as an attribute value.

API call

<protocol>://<ws-host>:<ws-port>/ws-api/v1/files/attachments?token=<sessionId>&filename=<filename>

Details

  • GET method
  • Content-Type in the header: application/json
  • Mandatory parameters: the session token (as a query string parameter or as a key-value pair in the header) and the filename (as a query string parameter)

Available filters

You can add the filters as query string parameters or as key-value pairs in the header:
FilterDescription
resourceType=<value>One of TASK, PROJECT, or PROJECT_GROUP. The default value is TASK.
resourceId=<value>The ID of the resource to which the file is attached.
attributeName=<value>The name of the attribute to which the file is attached.
downloadToken=<token>The token returned in the response after uploading the asset (if the asset is not attached to the resource).
Examples:
  • <protocol>://<ws-host>:<ws-port>/ws-api/v1/files/attachments?token=<sessionId>&filename=attr1113-8493849188859715237_ws_api.txt&resourceType=PROJECT
  • <protocol>://<ws-host>:<ws-port>/ws-api/v1/files/attachments?token=<sessionId>&filename=attr1113-8493849188859715237_ws_api.txt&resourceId=3486&attributeName=attachment&resourceType=PROJECT

Response

The contents of the requested attribute files.

Error messages

MessageStatus code
Source asset is not available for download (If resourceType=TASK, but the value of the resourceId is not the ID of a task.)400 Bad Request
No session token provided or invalid token401 Unauthorized
Resource PROJECT_GROUP (ID) not found (If resourceType=PROJECT_GROUP, but the value of the resourceId is not the ID of a project group.)404 Not Found
Resource PROJECT (ID) not found (If resourceType=PROJECT, but the value of the resourceId is not the ID of a project.)404 Not Found
Internal Server Error:
  • If the value of the resourceId is not a number.
  • If the value of the resourceType is not PROJECT, TASK, or PROJECT_GROUP.
500 Internal Server Error