1

I've got a project server app in which I hava a custom field that gets populated through a lookup table I've previously filled.

What I want is to get the value of this custom field using the REST API.

I've been able to get the custom field using:

_api/projectserver/Projects('GUID_Project')/CustomFields('GUID_CustomField')

and its lookupentries using:

_api/projectserver/Projects('GUID_Project')/CustomFields('GUID_CustomField')/LookupEntries

But I must be missing something because I can't find the way to link the custom field with its value.

Anyone knows how to do this?

2 Answers 2

5

Via the query

_api/ProjectServer/Projects('GUID_Project')/CustomFields('GUID_CustomField')

you can achieve only the definitions of the custom fields, but not their value.

To get the value, we need first the internal name of the field

_api/ProjectServer/Projects('GUID_Project')/CustomFields('GUID_CustomField')?$select=InternalName

For example, if the field ID is 203ee722-6449-e411-80dd-005056b44e32, the internal name will be Custom_203ee7226449e41180dd005056b44e32.

Next, get the all the the custom field values:

_api/ProjectServer/Projects('GUID_Project')/IncludeCustomFields

or only the one you need:

_api/ProjectServer/Projects('GUID_Project')/IncludeCustomFields?$select='InternalName_CustomField'

The value will be displayed as Entry_d13ce7226449e41180dd005056b44e32, that means lookup table entry ID d13ce722-6449-e411-80dd-005056b44e32.

To get the lookup table entry:

_api/ProjectServer/LookupTables('GUID_LookupTable')/Entries('GUID_LookupTableEntry')

or just its value:

_api/ProjectServer/LookupTables('GUID_LookupTable')/Entries('GUID_LookupTableEntry')?$select=FullValue

I hope it helps!

0
0

If you want just the custom field value, you can use the ProjectData service:

http://server/pwa/_api/projectdata/Projects(guid'GUID_Project')

That retrieves all the project properties, including all custom field values. You can use $select to retrieve only the properties you want:

http://server/pwa/_api/projectdata/Projects(guid'GUID_Project')?$select=CustomFieldName1,...,CustomFieldNameN

A few caveats:

  • The custom field name is not the name you give in the UI when creating the field. A simple way to get the name is to request the URL without the $select and look for the name in the response.
  • You may use browsers to test the URL response but some kind of REST client makes things smoother. I use Advanced Rest Client for Chrome and HttpRequester for FireFox.
  • The default response format is XML; you can get JSON by specifiying "application/json;odata=verbose" in the Accept header (just "application/json" will not work).
  • If you have a localized Project Server the "/Projects" segment of the URL will be localized too: my Project Server is PT-BR and the URL is http://server/pwa/_api/projectdata/Projetos(...). You can get the "entity sets" names by going to the address http://server/pwa/_api/projectdata/.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.