0

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?

1

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........"
}
  • If I remove the Id at the end of the endpoint I get 200 and a valid response. But when I add the Id I get 404. I got the Id from the url when looking at the Global Value Set in setup. I tried both with and without the prefix 0Nt, I'm not sure why it's not working – tom_12321 Sep 13 '18 at 23:26
  • @tom_12321 try running a query for it just to verify it's the right Id. – sfdcfox Sep 13 '18 at 23:28
  • GlobalValueSet is not a valid SObject to query when doing an SOQL query. How would I query it? – tom_12321 Sep 13 '18 at 23:32
  • @tom_12321 It's not a standard SOQL query, it's Tooling API query. Different list of available objects. – sfdcfox Sep 13 '18 at 23:34
  • Oh ok, thanks for that link! How would I query for it? Would I do it in an anonymous apex window? Or would i do it in workbench somewhere? – tom_12321 Sep 13 '18 at 23:39
1

I just tried the same endpoint on Salesforce Workbench. And I was able to access the global value set from it. Can you see if host is proper?

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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