0

(I was having an issue, it took me awhile to figure it out, and the Google search results and Salesforce documentation wasn't helping - so I'm posting this question, and the answer to my problem, so Google can provide better search results for anyone else having this issue)

I'm POSTing a Composite REST API call. My JSON looks like this:

{
"batchRequests": [
    {
        "method": "PATCH",
        "url": "/v47.0/composite/sobjects/Opportunity/0064P00000nR2yBZAS",
        "richInput": {
            "pymt__Shipping__c": "4.95",
            "pymt__Tax__c": "0",
            "CloseDate": "2020-01-11"
        }
    },
    {
        "method": "POST",
        "url": "/v47.0/composite/sobjects/OpportunityLineItem",
        "richInput": {
            "OpportunityId": "0064P00000nR2yBZAS",
            "UnitPrice": "49.95",
            "Quantity": "2"
        }
    },
    {
        "method": "POST",
        "url": "/v47.0/composite/sobjects/OpportunityLineItem",
        "richInput": {
            "OpportunityId": "0064P00000nR2yBZAS",
            "UnitPrice": "59.95",
            "Quantity": "1"
        }
    },
    {
        "method": "POST",
        "url": "/v47.0/composite/sobjects/OpportunityLineItem",
        "richInput": {
            "OpportunityId": "0064P00000nR2yBZAS",
            "UnitPrice": "34.95",
            "Quantity": "1"
        }
    }
]}

My response is:

    {
  "hasErrors": true,
  "results": [
    {
      "result": [
        {
          "errorCode": "INVALID_BATCH_REQUEST",
          "message": "Cannot access this resource in a batch request"
        }
      ],
      "statusCode": 400
    },
    {
      "result": [
        {
          "errorCode": "INVALID_BATCH_REQUEST",
          "message": "Cannot access this resource in a batch request"
        }
      ],
      "statusCode": 400
    },
    {
      "result": [
        {
          "errorCode": "INVALID_BATCH_REQUEST",
          "message": "Cannot access this resource in a batch request"
        }
      ],
      "statusCode": 400
    },
    {
      "result": [
        {
          "errorCode": "INVALID_BATCH_REQUEST",
          "message": "Cannot access this resource in a batch request"
        }
      ],
      "statusCode": 400
    }
  ]}

Why is it saying INVALID_BATCH_REQUEST and "Cannot access this resource in a batch request"?

1 Answer 1

1

The problem is, you're providing the wrong URIs, which is why Salesforce "Can't access the resource".

You were probably looking at this page, and saw "/vXX.X/composite/sobjects". and thought your Batch request URIs were supposed to have "/composite/" in them - they're not.

If you change your URIs to "/v47.0/sobjects/OpportunityLineItem" (as shown on this page), they should work.

You must log in to answer this question.

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