Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with POST #90

Closed
spoonwzd opened this issue May 6, 2024 · 3 comments
Closed

Issues with POST #90

spoonwzd opened this issue May 6, 2024 · 3 comments

Comments

@spoonwzd
Copy link

spoonwzd commented May 6, 2024

Things have stopped working for me since you implemented POST.

I can set the reserve correctly using POST using curl from your example, but when I set the method in my node-red function to POST it says my token is bad.

"{"unauthorized": "Control Command Token Invalid"}"

I'm not sure what I'm doing wrong. It should be as simple as changing msg.method in my custom function:

if (powerwall_reserve!=charge_level && overnight_charge===true) {
    msg.method = "POST"
    msg.url = "http://192.168.78.40:8675/control/reserve?token=MY_TOKEN&value=" + charge_level
return msg;

The only thing I can see different is your example sets the value before the token. Should this matter?

Any ideas?

@jasonacox
Copy link
Owner

POST sends the payload via a message versus on the URL. I think you would need something like this:

if (powerwall_reserve != charge_level && overnight_charge === true) {
    msg.method = "POST";
    msg.url = "http://192.168.78.40:8675/control/reserve";
    msg.payload = "token=MY_TOKEN&value=" + charge_level;
    return msg;
}

@spoonwzd
Copy link
Author

spoonwzd commented May 7, 2024

Yup that was the secret sauce - thanks!

@jasonacox
Copy link
Owner

Thanks for testing, @spoonwzd ! I'll close this but feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants