I experienced this same error when my URL wasn't setup properly. Seems like a no brainer, but worth ensuring the URL you are constructing and passing is correct/what you want.