4

I'm trying to create multiple ApexClassMember records via REST Tooling API calls.

In official documentation they claim, that You can Create Multiple Records with Fewer Round-Trips

However, in workbench such request returns error "Service not found at: /services/data/v54.0/tooling/composite/sobjects" enter image description here

My request body

{
  "records": [
{
  "attributes": {
    "type": "ApexClassMember"
  },
  "metadataContainerId": "1dc78000000Gt2nAAC",
  "contentEntityId": "01p78000000CxJ6AAK",
  "body": ""
},
{
  "attributes": {
    "type": "ApexClassMember"
  },
  "metadataContainerId": "1dc78000000Gt2nAAC",
  "contentEntityId": "01p78000000Cw6zAAC",
  "body": ""
}]}

Moreover, record retrieval also does not work. It looks like the whole /tooling/composite does not work.

0

1 Answer 1

4

Definitely a doc bug - as it seems no tooling object supports it. It's sort-of mentioned in this answer - though it says "most objects" don't support it. Yet, I haven't seen an object work on that given endpoint: composite/sobjects.

For your situation, ApexClassMember is also not available in the REST API composite sobjects endpoint either - so it seems you have no option to bulkify your POST call.

For GET, you can use the composite resource (services/data/v54.0/tooling/composite) to do bulk queries on ApexClassMember - you can utilize the query endpoint or the Id of ApexClassMember

{
   "allOrNone" : true,
   "compositeRequest" : [
       {
          "method": "GET",
          "referenceId": "queryWithApexClassMember",
          "url": "/services/data/v54.0/tooling/sobjects/ApexClassMember/400XXXXXXXXXXXX"
       },
       {
          "method": "GET",
          "referenceId": "query2",
          "url": "/services/data/v54.0/tooling/query?q=SELECT+ID+FROM+ApexClassMember"
       }
 
    ]
}

However, when you try to utilize POST on ApexMemberClass in the composite endpoint, you get the following message

"body" : [ {
      "errorCode" : "METHOD_NOT_ALLOWED",
      "message" : "HTTP Method 'POST' not allowed. Allowed are HEAD,GET,PATCH,DELETE"
    } ]

Testing various tooling objects (haven't tested all), they all seem to throw the same error as above.

2
  • 2
    A doc update would be much appreciated. As everyone knows, half the frustration is the docs being vague.
    – identigral
    Commented Mar 14, 2022 at 16:28
  • 1
    100% agree. FWIW, there's a work item for it regarding updating the documentation. Commented Mar 14, 2022 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .