I found the answer, it wants a reference so put &buffer instead of buffer. Why is it that you always find the answer right after posting a question?
I'll set this as the answer in a few days