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

404 when posting Charge Plan to Rest API and using UTC+X offset #16827

Closed
1 task done
tmsch13 opened this issue Oct 24, 2024 · 12 comments · Fixed by #16846
Closed
1 task done

404 when posting Charge Plan to Rest API and using UTC+X offset #16827

tmsch13 opened this issue Oct 24, 2024 · 12 comments · Fixed by #16846
Labels
bug Something isn't working

Comments

@tmsch13
Copy link

tmsch13 commented Oct 24, 2024

Describe the bug

I just tried the evcc Rest api while debugging a openhab EVCC Binding problem (link) and i think the API its not working correct:

curl -X POST "http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/2024-10-25T05:30:00Z"
{"result":{"soc":90,"time":"2024-10-25T05:30:00Z"}}

curl -X POST "http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/2024-10-25T05:30:00-01:00"
{"result":{"soc":90,"time":"2024-10-25T05:30:00-01:00"}}

curl -X POST "http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/2024-10-25T05:30:00+01:00"
404 page not found

I also tried URLencoding, but doesn’t work neither.

curl -X POST http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/2024-10-25T05:30:00%2B01:00
404 page not found

so positive offsets from Zulu time (aka UTC ) don’t work.

Steps to reproduce

  1. curl -X POST "http://:7070/api/vehicles//plan/soc/90/2024-10-25T05:30:00+01:00"

Configuration details

Version 0.131.1 on Debian 11.8

Log details

No Logging even in debug mode, i just see "404 page not found“ at the client

What type of operating system are you running?

Linux

Nightly build

  • I have verified that the issue is reproducible with the latest nightly build

Version

0.131.1

@andig
Copy link
Member

andig commented Oct 24, 2024

You'll need to follow

RFC3339     = "2006-01-02T15:04:05Z07:00"

@andig andig closed this as completed Oct 24, 2024
@andig andig added the question Rather clarification than issue label Oct 24, 2024
@Laith-Budairi
Copy link

Laith-Budairi commented Oct 24, 2024

You'll need to follow

RFC3339     = "2006-01-02T15:04:05Z07:00"

not working. I even tried to encode the URL

image

@andig
Copy link
Member

andig commented Oct 24, 2024

Whats the curl?

@Laith-Budairi
Copy link

Whats the curl?

a shown on Postman:

curl --location --request POST 'https://demo.evcc.io/api/vehicles/vehicle_1/plan/soc/100/2006-01-02T15:04:05Z07:00'
--header 'Authorization: ••••••'
--data ''

@andig
Copy link
Member

andig commented Oct 24, 2024

Z is only for Zulu/UTC, see https://play.golang.com/p/R7tDMj8opCT

@andig
Copy link
Member

andig commented Oct 24, 2024

This PR should make it easier to work with the API, at least for local users.

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

@andig :

You'll need to follow

RFC3339     = "2006-01-02T15:04:05Z07:00"

Sorry, but I think, Z followed by a Number is not RFC3339 and as @Laith-Budairi showed, is not working, results is:
{"error":"parsing time "2024-10-25T15:30:00Z02:00": extra text: "02:00""}

When reading the examples in the RFC3339 definition https://datatracker.ietf.org/doc/html/rfc3339#section-5.8 I would understand that RFC3339 allows

2024-10-25T05:30:00Z (if Zulu aka UTC)
2024-10-25T05:30:00-02:00 (if UTC minus 2 hours)
2024-10-25T05:30:00+02:00 (if UTC plus 2 hours)

which is exactly what I tested and what did not work!

I tried in your go playground, and + and - are working, see here: https://play.golang.com/p/DaEVAVHnTgJ

So, as (time.Parse(time.RFC3339 can handle Z, + and - but EVCC can’t, the problem is maybe in receiving the + character, i tried URLencoding, but that didn’t help neither.

@andig
Copy link
Member

andig commented Oct 24, 2024

So, as (time.Parse(time.RFC3339 can handle Z, + and - but EVCC can’t, the problem is maybe in receiving the + character, i tried URLencoding, but that didn’t help neither.

It can (in principle). You just can‘t use Z and +/- together. And maybe the regex is missing the +, need to check.

which is exactly what I tested and what did not work!

It does, see the play.

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

Yeah in play it is working, but with curl and the actual EVCC API it is not. Have you tried?

in go play:
fmt.Println(time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00")) // UTC +7:00

-> 2006-01-02 15:04:05 +0700 +0700

but in curl:

curl -X POST "http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/**2006-01-02T15:04:05+07:00**"
404 page not found

And of course you can’t use Z and +/- together. I never did, but you in your comment: #16827 (comment) thats why Laith and I tested it.

@premultiply
Copy link
Member

+ may have a special meaning in URL. Needs to be URLencoded?

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

I tested URLencoding (see initial bug report at the top) was not working.

@andig andig added bug Something isn't working and removed question Rather clarification than issue labels Oct 25, 2024
@tmsch13
Copy link
Author

tmsch13 commented Oct 26, 2024

Tested with the new nightly build and its working now.
Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants