The issue you have, and the issue you think you have, are two different things. You actually have a few different issues in this code.
I think that you've probably paraphrased your code here, but you've omitted some important details. That, or you haven't copied and pasted the error message that you're getting word-for-word. If you're going to make changes to your code when sharing it here, you need to be making those changes consistently (else you run the risk of confusing people, like you have here).
I vaguely recall seeing the
shouldProcessAsync() method as an answer to another question. If you're asking a new question based on things you did from another question, you really should be providing that context.
Anyway, getting to the issues...
record is not defined anywhere
The error you're getting is very straightforward. Setting aside the mismatch between your code and your error message, line 11 is
Take a look at your code. I don't see a declaration for a
post variable anywhere. It's also not one of your method arguments.
No declaration = no variable. If you try to use a variable that doesn't exist, you'll get a "variable does not exist" error. Pretty simple.
Getting rid of the error is a simple matter. Declare your variable somewhere (in the method, as a class variable, make it an argument to your
The gotcha here if you make this a class variable is that it would need to be a
static variable. Static methods can make use of static class variables only. Non-static methods can make use of instance (non-static) class variables as well as static class variables.
Your call to
isEmpty() suggests that this should be a collection of some sort.
The above would fix the syntax of your code, but not the semantics. You'll need to figure out how to make
record.isEmpty() not be true (or change that code or change its location), or you'll never do any work. Fixing the semantics is out of scope for this question and, even if it weren't, you haven't provided enough context to make any suggestions here.
Your call to your async method is wrong
Or rather, you aren't calling it at all.
The next lines, after your error, are
if statement here indicates that you do want to go async, but then you go and recursively call the
POST() method instead. You should be calling
Your @future method is passing the wrong parameters back to
Look at the method signature for
It takes two strings.
Now take a look at your
It's trying to pass a
List<Account> is not the same as two
Strings. This will cause an error.
One thing that's probably not an issue is your switching between
post(). Most (if not all) identifiers, including method names, are case-insensitive in Apex.
It does, however, make things more confusing when you switch between capitalization styles. You can continue to call your method like
post(), but that's not great practice. Pick a style, and stick with it.
I think this is a good demonstration of what happens when you copy & paste code from others without understanding what it does or how it fits in with your existing code.
You need to go back and evaluate what you're trying to do here. Once you have your base code (i.e. your basic callout logic/processing) in a compilable state, and write good unit tests to exercise the behavior, you can move on to trying to understand and integrate asynchronous operation into that.
Trying to change too many things at once is as bad for programming as it is for science.