[SalesForce] Endpoint for getting GlobalValueSet using REST API

I'm trying to use the REST API to get the list of values for a Global Value Set. Since it is not a field on a specific SObject, I don't think you can query for the values. I am successfully authenticated and have a valid REST call, but am getting a 404 response. I think it must have something to do with my endpoint I defined:

req.setEndpoint('https://'+host+'/services/data/v41.0/tooling/sobjects/GlobalValueSet/<myId>');

Is GlobalValueSet in the endpoint correct?

Best Answer

You can query for GlobalValueSet via the Tooling API:

/services/data/v41.0/tooling/query?q=select+id+from+globalvalueset

And, if you had the right URL, you'd get a valid response:

/services/data/v41.0/tooling/sobjects/GlobalValueSet/0Nt..........

Make sure you use the full Id, should start with 0Nt.

Response will be something like:

{
  "attributes" : {
    "type" : "GlobalValueSet",
    "url" : "/services/data/v41.0/tooling/sobjects/GlobalValueSet/0Nt....."
  },
  "Metadata" : {
    "customValue" : [ {
      "color" : null,
      "default" : false,
      "description" : null,
      "isActive" : null,
      "label" : "Yes",
      "urls" : null,
      "valueName" : "Yes"
    }, {
      "color" : null,
      "default" : false,
      "description" : null,
      "isActive" : null,
      "label" : "No",
      "urls" : null,
      "valueName" : "No"
    } ],
    "description" : null,
    "masterLabel" : "Value Label",
    "sorted" : false,
    "urls" : null
  },
  "FullName" : "Value_Label",
  "Id" : "0Nt...",
  "DeveloperName" : "Value_Label",
  "MasterLabel" : "Value Label",
  "Description" : null,
  "NamespacePrefix" : null,
  "ManageableState" : "unmanaged",
  "CreatedDate" : "2018-03-13T04:12:06.000+0000",
  "CreatedById" : "005........",
  "LastModifiedDate" : "2018-03-13T04:12:06.000+0000",
  "LastModifiedById" : "005........"
}
Related Topic