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

/actions/charging-start -> {"code":"err.func.wired.invalid-body-format","message":"Body has at least one wrongly formatted value"} #1247

Open
fin2red opened this issue Jun 30, 2024 · 7 comments

Comments

@fin2red
Copy link

fin2red commented Jun 30, 2024

Hello,

I've been trying a number of ways to call /actions/charging-start (the first action that I'm trying to call), but I'm always getting an error. The GET requests work well.

I'm not sure if I'm missing some header, or missing something in the payload, but here's a minimal example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-type: application/vnd.api+json',
    'x-gigya-id_token: '.$CONFIG['gigyaJWT'],
    'apikey: '.$CONFIG['kamereon_key']
]);

curl_setopt($ch, CURLOPT_URL, sprintf(
    "https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1/accounts/%s/kamereon/kca/car-adapter/v1/cars/%s/actions/charging-start?country=PT",
    $CONFIG['accountId'],
    $CONFIG['vin']
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"data":{"type": "ChargingStart","attributes":{"action":"stop"}}}');
$json_raw = curl_exec($ch);

I also tried application/json as the Content-type, and removing/adding spaces in the JSON, also different cURL options, etc...

But I always get:

{"type":"FUNCTIONAL","messages":[{"code":"err.func.wired.invalid-body-format","message":"Body has at least one wrongly formatted value"}],"errors":[{"errorCode":"err.func.wired.invalid-body-format","errorMessage":"Body has at least one wrongly formatted value"}],"error_reference":"FUNCTIONAL"}

Any idea why?

It seems consistent as per the documentation:
https://renault-api.readthedocs.io/en/stable/endpoints.html#actions-charging-start

And as per the payload in this comment:
#763 (comment)

So, I'm not sure what I'm doing wrong!
Thank you!

@jumpjack
Copy link

jumpjack commented Jul 1, 2024

Forget charging-start, you must use "actions/charge-mode" with this payloads:

Start charging:

{
    "data": {
        "type": "ChargeMode",
        "attributes": {
            "action": "always_charging"
        }
    }
}

Stop charging:

{
    "data": {
        "type": "ChargeMode",
        "attributes": {
            "action": "schedule_mode"
        }
    }
}

And you will need at least one charging schedule already active.

@fin2red
Copy link
Author

fin2red commented Jul 1, 2024

Thank you very much!!

Does that mean that if I want to start charging (by plugging), I need to call "always_charging" first, or otherwise it won't start charging, because it's on "schedule_mode" since the last time I requested to stop charge?

@jumpjack
Copy link

jumpjack commented Jul 3, 2024

Good question. I didn't verify that, I always stopped by hand directly on the car, but I think you are right: if you use this method, you'll have to switch back to "always" once you disconnect.

But the real problem is that your command is not accepted at all, while usually it is accepted but not executed because improperly formatted.

I just noticed that I am receiving same error on my test page (warning: use it at your own risk, use a temporary password!): "start" is accepted, "stop" is not, hence something changed in the api: or "stop" has been changed to something else, or there is a new endpoint like "charging-stop"; I tried some new random names, but no luck.

@jumpjack
Copy link

jumpjack commented Jul 3, 2024

My new discoveries:

{
"data": {
"type": "ChargingStart",
"attributes": {
"action": PARAMETER
}
}
}

PARAMETER value --> server response:
0 -->

{
    "data": {
        "type": "ChargingStart",
        "id": "ea11e720-b9f2-47bf-bcf3-3031bb364bb5",
        "attributes": {
            "action": "start"
        }
    }
}

1 --> Action must be 'start' but was 'pause'
2 --> Action must be 'start' but was 'resume'
3 --> Body has at least one wrongly formatted value

@fin2red
Copy link
Author

fin2red commented Jul 3, 2024

Thank you for your responses!

But sorry - I'm not sure I understand your last discovery.

Are you saying that we can call "ChargingStart", but instead of "start" or "stop", we can put "0", "1", "2", etc... ?

So I guess "0" or "start" works for starting, but you couldn't find one that works for stopping.

Thank you again.

@jumpjack
Copy link

jumpjack commented Jul 4, 2024

As far as I can understand, you can use "raw values" 0, 1 or 2, or the equivalent strings "start", "pause" and "resume", but "start" is only for /actions/charging-start endpoint, I am trying to figure out which is the right one for pause and resume.
Instead, apparently "stop" is not an allowed option.

@jumpjack
Copy link

jumpjack commented Jul 4, 2024

Ok here it is (but no tested yet):

/commerce/v1/accounts/ACCOUNT/kamereon/kcm/v1/vehicles/VIN/charge/pause-resume

payload:
{"data":{"type": "ChargePauseResume","attributes": { "action": "pause" } }}

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