I want to bind variable in get request, but it gives me error "Bind variables only allowed in Apex code","errorCode":"MALFORMED_QUERY"}". How to do it?

Account account  =  new Account(name = 'test');
request.setEndpoint('https://login.salesforce.com/services/data/v52.0/query/' +
  • What are you actually trying to accomplish here? There's no need to callout to query your own org, and that Account has no Id because you didn't insert it. Please edit to provide context and clarity.
    – David Reed
    Commented Aug 18, 2021 at 15:44
  • @DavidReed i am calling to another org. Account var i wrote just for here example, cause there are many code.
    – Solmetirka
    Commented Aug 18, 2021 at 15:47

1 Answer 1


You need to put the value directly in to the query string:

request.setEndpoint('https://login.salesforce.com/services/data/v52.0/query/' +

You cannot bind to the variable in a callout, because it has to be interpolated directly into the string. This is a limitation of how HTTP callouts work in general.

  • got it, thanks.Seems good.
    – Solmetirka
    Commented Aug 18, 2021 at 15:53

You must log in to answer this question.

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