Wednesday 19 December 2018

Check custom field name for select & filter in API project online

A simple post to remind me how to check name to be used in REST project online web service. For example, I've this custom field "Initiative/Project ID". What would be the name when we want to call REST project online?
We could check the internal names using the following xml from URL:
https://{site collection name}/sites/pwa/_api/ProjectServer/CustomFields

But we couldn't use internal names for calling REST project online. REST project use custom field name and not internal ones.
However, we could get that name from PowerBI desktop.
Here's how I did it:
  1. Open PowerBI
  2. Click on GetData
  3. Click on Other > OData Feed
  4. Enter URL https://{site collection name}/sites/pwa/_api/projectdata
  5. Mark Projects and Click Load
  6. Search for your custom field on FIELDS list on the right
  7. You will find your custom field name like this
So "Initiative/Project ID" will become "InitiativeProjectID", we could use this name to call REST project online. This is an URL example on how we could find & retrieve "Initiative/Project ID".

https://{site collection name}/sites/pwa/_api/ProjectData/Projects()?$filter=InitiativeProjectID eq 'PROJECTID001' and ProjectType ne 7&$select=InitiativeProjectID