Documentation Center

Get cost models

Get a list of the cost models defined on your system.

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.

API call

<protocol>://<ws-host>:<ws-port>/ws-api/v1/costModels?token=<sessionId>

Details

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

Available filters

You can add the filters as query string parameters or as key-value pairs in the header:
FilterDescription
sortBy=<fieldName>If the fields you specified for sorting (for example, name or description) are not available, the results will not be sorted.
sortDirection=<asc|desc>Ascending or descending.
fields=<fieldName1,fieldName2,…,fieldNameN>The names of the fields to be included in the JSON response, separated by commas. Do not use in conjunction with the excludedFields filter. The accessType field will always be included in the result.
excludedFields=<fieldName1,fieldName2,…,fieldNameN>The names of the fields to be excluded from the JSON response, separated by commas. Do not use in conjunction with the fields filter. The accessType field will always be included in the result, even if you exclude it.
scopingId=<value>The ID of the scoping configuration.
localeId=<value>The ID of the source locale.
Examples:
  • <protocol>://<ws-host>:<ws-port>/ws-api/v1/costModels?token=<sessionId>&fields=id,name
  • <protocol>://<ws-host>:<ws-port>/ws-api/v1/costModels?token=<sessionId>&fields=id,description&sortBy=description&sortDirection=desc
  • <protocol>://<ws-host>:<ws-port>/ws-api/v1/costModels?token=<sessionId>&localeId=1017

Advanced filtering

To reduce the amount of data in the result and to improve performance, you can perform the filtering deeper in the returned model tree structure. For example: <protocol>://<ws-host>:<ws-port>/ws-api/v1/costModels?token=<sessionId>&fields=id,name,language(id,locale),acl(users(level,granteeId))

In this case, the returned JSON contains only the fields you specified for each layer:
  • The ID, the name, the language, and access control list (ACL) information about each cost model.
  • The ID and the locale of each language.
  • The reduced ACL model, containing user information (the level and the grantee ID).
The same logic applies to the excludedFields filter.

Response

A screen shot that shows a typical response to this call.

Error messages

MessageStatus code
Required filter localeId not provided, or invalid (If one of the locale IDs that you entered is not a valid number.) 400 Bad Request
Required filter scopingId not provided, or invalid (If one of the scoping IDs that you entered is not a valid number.) 400 Bad Request
No session token provided or invalid token401 Unauthorized