Carwings API?

My Nissan Leaf Forum

Help Support My Nissan Leaf Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
So... If the api is still live.. Can someone help me with why my code is not working? Please..
 
you specify the request without the server name
xmlhttp.open('POST', '/aqPortal/v2/smartphoneProxy/vehicleService', true);

so that request would be sent to /aqPortal/v2/smartphoneProxy/vehicleService on the same server as the script is placed I believe...

for the US server you would have to change it to:
xmlhttp.open('POST', 'https://nissan-na-smartphone-biz.viaaq.com/aqPortal/v2/smartphoneProxy/vehicleService', true);

however... this is the wrong url to send login requests to.. you need to send those to the userService urls (and then remember to keep the session and loadbalancer cookies and include those in the following calls to the vehicleService)
 
Hi gyathaar,

thanks for the info. Let me try this out. By the way, I absolutely love the your android app! use that instead of the nissan company app!

.Uday
 
For anyone who is interested, I've started to work on a Node.js module for accessing the Carwings API. You can see my code here:

https://github.com/crabasa/carwingsjs" onclick="window.open(this.href);return false;
 
Has the API changed?

I can't even log in without generating an HTTP 500 error. I'm using the example posted on the EV wiki (user/pass updated of course). Do any of the other fields have to be changed?
 
lion said:
Still haven't figured this out, so confirmation would really be helpful :)

I can only say that the third-party control app I use (LEAFmanager) has continued to work fine without an update, so I suspect that the API has not changed (or at least the ones that it uses).
 
Hi everyone, new Leaf owner here!

I'm playing with the REST endpoints. I'm using Postman to post this package to https://nissan-na-smartphone-biz.viaaq.com/aqPortal/smartphoneProxy/userService" onclick="window.open(this.href);return false;:

Code:
<?xml version="1.0"?>
<ns2:SmartphoneLoginWithAdditionalOperationRequest 
  xmlns:ns4="urn:com:hitachi:gdc:type:report:v1" xmlns:ns7="urn:com:airbiquity:smartphone.vehicleservice:v1"   
  xmlns:ns3="http://www.nissanusa.com/owners/schemas/api/0" xmlns:ns5="urn:com:airbiquity:smartphone.reportservice:v1"
  xmlns:ns2="urn:com:airbiquity:smartphone.userservices:v1" xmlns:ns6="urn:com:hitachi:gdc:type:vehicle:v1">
  <SmartphoneLoginInfo>
    <UserLoginInfo>
      <userId>vkapadia</userId>
      <userPassword>mypassword</userPassword>
    </UserLoginInfo>
    <DeviceToken>DUMMY1313820504.22296500</DeviceToken>
    <UUID>randomly generated guid</UUID>
    <Locale>US</Locale>
    <AppVersion>1.40</AppVersion>
    <SmartphoneType>ANDROID</SmartphoneType>
  </SmartphoneLoginInfo>
  <SmartphoneOperationType>SmartphoneGetPreferencesRequest</SmartphoneOperationType>
  <SmartphoneOperationType>SmartphoneLatestBatteryStatusRequest</SmartphoneOperationType>
  <SmartphoneOperationType>SmartphoneLatestACStatusRequest</SmartphoneOperationType>
  <SmartphoneOperationType>SmartphoneGetScheduledACRemoteRequest</SmartphoneOperationType>
</ns2:SmartphoneLoginWithAdditionalOperationRequest>

It gives me this back:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:SmartphoneLoginWithAdditionalOperationResponse
    xmlns:ns4="urn:com:airbiquity:smartphone.reportservice:v1"
    xmlns:ns7="urn:com:airbiquity:smartphone.common:v1"
    xmlns:ns3="urn:com:hitachi:gdc:type:report:v1"
    xmlns:ns5="urn:com:hitachi:gdc:type:vehicle:v1"
    xmlns:ns2="urn:com:airbiquity:smartphone.userservices:v1"
    xmlns:ns6="urn:com:airbiquity:smartphone.vehicleservice:v1">
    <SmartphoneUserInfoType>
        <VehicleInfo>
            <Vin>my vin</Vin>
        </VehicleInfo>
        <Nickname>VinayLEAF</Nickname>
    </SmartphoneUserInfoType>
    <ns4:SmartphoneLatestBatteryStatusResponse>
        <SmartphoneBatteryStatusResponseType>
            <ns3:BatteryStatusRecords>
                <ns3:OperationResult>START</ns3:OperationResult>
                <ns3:OperationDateAndTime>2015-06-23T18:41:13.0</ns3:OperationDateAndTime>
                <ns3:BatteryStatus>
                    <ns3:BatteryChargingStatus>NOT_CHARGING</ns3:BatteryChargingStatus>
                    <ns3:BatteryCapacity>12</ns3:BatteryCapacity>
                    <ns3:BatteryRemainingAmount>7</ns3:BatteryRemainingAmount>
                </ns3:BatteryStatus>
                <ns3:PluginState>NOT_CONNECTED</ns3:PluginState>
                <ns3:CruisingRangeAcOn>95400</ns3:CruisingRangeAcOn>
                <ns3:CruisingRangeAcOff>100488</ns3:CruisingRangeAcOff>
                <ns3:TimeRequiredToFull>
                    <ns3:HourRequiredToFull>10</ns3:HourRequiredToFull>
                    <ns3:MinutesRequiredToFull>30</ns3:MinutesRequiredToFull>
                </ns3:TimeRequiredToFull>
                <ns3:TimeRequiredToFull200>
                    <ns3:HourRequiredToFull>4</ns3:HourRequiredToFull>
                    <ns3:MinutesRequiredToFull>0</ns3:MinutesRequiredToFull>
                </ns3:TimeRequiredToFull200>
                <ns3:NotificationDateAndTime>2015-06-23T18:41:27.0</ns3:NotificationDateAndTime>
            </ns3:BatteryStatusRecords>
            <VehicleInfo>
                <Vin>1N4AZ0CP5FC303713</Vin>
            </VehicleInfo>
            <lastBatteryStatusCheckExecutionTime>2015-06-23T18:41:13.000Z</lastBatteryStatusCheckExecutionTime>
        </SmartphoneBatteryStatusResponseType>
    </ns4:SmartphoneLatestBatteryStatusResponse>
    <ns4:SmartphoneLatestACStatusResponse>
        <SmartphoneACStatusResponseType>
            <ns3:RemoteACRecords>
                <ns3:OperationResult>FINISH</ns3:OperationResult>
                <ns3:OperationDateAndTime>2015-06-20T23:21:16.0</ns3:OperationDateAndTime>
                <ns3:RemoteACOperation>START</ns3:RemoteACOperation>
                <ns3:ACStartStopDateAndTime>2015-06-20T23:21:16.0</ns3:ACStartStopDateAndTime>
                <ns3:CruisingRangeAcOn>57960</ns3:CruisingRangeAcOn>
                <ns3:CruisingRangeAcOff>60720</ns3:CruisingRangeAcOff>
                <ns3:ACStartStopURL></ns3:ACStartStopURL>
                <ns3:PluginState>NOT_CONNECTED</ns3:PluginState>
                <ns3:ACDurationBatterySec>900</ns3:ACDurationBatterySec>
                <ns3:ACDurationPluggedSec>7200</ns3:ACDurationPluggedSec>
            </ns3:RemoteACRecords>
            <VehicleInfo>
                <Vin>my vin</Vin>
            </VehicleInfo>
        </SmartphoneACStatusResponseType>
    </ns4:SmartphoneLatestACStatusResponse>
    <ns2:SmartphoneGetPreferencesResponse>
        <NotificationPreferencesType>
            <vin>my vin</vin>
            <chargeStatusApple>false</chargeStatusApple>
            <chargeStatusEmail>true</chargeStatusEmail>
            <chargeStatusSms>true</chargeStatusSms>
            <plugInReminderApple>false</plugInReminderApple>
            <plugInReminderEmail>true</plugInReminderEmail>
            <plugInReminderSms>true</plugInReminderSms>
            <chargeCompleteApple>false</chargeCompleteApple>
            <chargeCompleteEmail>true</chargeCompleteEmail>
            <chargeCompleteSms>true</chargeCompleteSms>
            <hvacOnApple>false</hvacOnApple>
            <hvacOnEmail>true</hvacOnEmail>
            <hvacOnSms>true</hvacOnSms>
            <vehicleChargeApple>false</vehicleChargeApple>
            <vehicleChargeEmail>true</vehicleChargeEmail>
            <vehicleChargeSms>true</vehicleChargeSms>
        </NotificationPreferencesType>
    </ns2:SmartphoneGetPreferencesResponse>
    <ns6:SmartphoneRemoteGetScheduledACResponse>
        <SmartphoneRemoteGetScheduledACResponseType>
            <ns5:GetScheduledACRemoteResponse/>
            <VehicleInfo>
                <Vin>my vin</Vin>
            </VehicleInfo>
        </SmartphoneRemoteGetScheduledACResponseType>
    </ns6:SmartphoneRemoteGetScheduledACResponse>
</ns2:SmartphoneLoginWithAdditionalOperationResponse>

So far so good. But it's old data. How do I request an update? I'm trying to post this package to https://nissan-na-smartphone-biz.viaaq.com/aqPortal/smartphoneProxy/vehicleService" onclick="window.open(this.href);return false;:

Code:
<?xml version="1.0"?>
<ns4:SmartphoneRemoteBatteryStatusCheckRequest
  xmlns:ns4="urn:com:hitachi:gdc:type:report:v1" xmlns:ns7="urn:com:airbiquity:smartphone.vehicleservice:v1"   
  xmlns:ns3="http://www.nissanusa.com/owners/schemas/api/0" xmlns:ns5="urn:com:airbiquity:smartphone.reportservice:v1"
  xmlns:ns2="urn:com:airbiquity:smartphone.userservices:v1" xmlns:ns6="urn:com:hitachi:gdc:type:vehicle:v1">
  <ns3:BatteryStatusCheckRequest>
    <ns3:VehicleServiceRequestHeader>
      <ns2:VIN>my vin</ns2:VIN>
    </ns3:VehicleServiceRequestHeader>
  </ns3:BatteryStatusCheckRequest>
</ns4:SmartphoneRemoteBatteryStatusCheckRequest>

But it gives me an HTTP 500 error (The server encountered an internal error () that prevented it from fulfilling this request.)

Any ideas? Would also love to be able to send messages to turn on AC etc.
 
I dont remember the correct xml in my head, but assuming what you have is correct..

Do you pass along the cookies you got from the login call?
 
Hi

I'm using the https://github.com/haykinson/pycarwings script to implement controlling my Leaf in my Home automation system, byt i really need help on the AC-function.

Does anyone know how to implement AC On/Off into this script or in any script for that matter. Either as a toggle-function or 2 separate scripts, respectively on and of?

On beforehand huge thanks! :)
 
Has anyone gotten this to work since the migration to the "NissanConnect EV" service? The old API calls don't seem to be working for me anymore.

-Jeremy
 
irwinr said:
Has anyone gotten this to work since the migration to the "NissanConnect EV" service? The old API calls don't seem to be working for me anymore.

-Jeremy

I thought said it works as long as you use your new login you have to create. The Nissan Leaf app was not updated as a part of the change to NissanConnect EV, so it's using the same interface it was using before.
 
The app actually was updated, I specifically remember being prompted to update at the beginning of October, but you could be right, the old interface may still supposedly work. It's just not working for me using either my new username nor my old username, and I'm not sure if it's something on Nissan's side or mine.

I actually just finished setting up mitmproxy to intercept the traffic, and the updated Nissan LEAF app actually uses a slightly different URL (It has "v3" in it now). It's not using the same URL it used before.

But even using the new URL, if I copy paste the XML into a curl request:

Code:
$  curl [email protected] https://nissan-na-smartphone-biz.viaaq.com/aqPortal/v3/smartphoneProxy/userService 
<html><head><title>JBossWeb/2.0.0.GA_CP05 - Error report</title><style></style> </head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" noshade="noshade"><h3>JBossWeb/2.0.0.GA_CP05</h3></body></html>

But there's no HTTP_USER or HTTP_PASSWORD being passed according to mitmproxy, so I'm not sure why it's saying it needs HTTP auth when the app is clearly not using it.
 
Just in case anyone else is working on this: I noticed that there is an extra HTTP Header that I didn't notice before in the initial login called "AppToken". It's a base64 encoded version of this:

Code:
SmartPhoneKeyVersion=1;SmartPhoneType=ANDROID;UUID=<my Phones UUID>

So it seems this header has to be added to any requests and it treats it as the "authentication":

There is also another header called AccessKeyID:
Code:
AccessKeyID:      A1r619u1ty!

BOTH of these new headers have to be present to access the new service.

-Jeremy
 
Jeremy,

Can you please post a trace of the login/command process? I'm having trouble myself now, so having a trace (personal info removed) would allow me to see where I'm going wrong.
 
irwinr said:
Just in case anyone else is working on this: I noticed that there is an extra HTTP Header that I didn't notice before in the initial login called "AppToken". It's a base64 encoded version of this:

Code:
SmartPhoneKeyVersion=1;SmartPhoneType=ANDROID;UUID=<my Phones UUID>

So it seems this header has to be added to any requests and it treats it as the "authentication":

There is also another header called AccessKeyID:
Code:
AccessKeyID:      A1r619u1ty!

BOTH of these new headers have to be present to access the new service.

-Jeremy

thanks Jeremy. For some reason the old APIs (https://nissan-na-smartphone-biz.viaaq.com/aqPortal/smartphoneProxy/) still seems to be working and I just tested and most of the functionality is fine (login, request update, Start climate control). Is that expected, one of your earlier post suggested it should not be working.

Just to make sure my app is future proof I tried the new v3 api with your suggestions on AccessKeyId and AppToken in headers and I am still getting "This request requires HTTP authentication" error message. Any suggestion on how to proceed or a sample trace like IIama suggests would be helpful as well.

thanks!
 
BluesBro said:
Hi

I'm using the https://github.com/haykinson/pycarwings script to implement controlling my Leaf in my Home automation system, byt i really need help on the AC-function.

Does anyone know how to implement AC On/Off into this script or in any script for that matter. Either as a toggle-function or 2 separate scripts, respectively on and of?

On beforehand huge thanks! :)

I see a great deal of people here who has this API working. Is there a way to make a simple shell or python script to make a AC toggle function?
 
grangan said:
irwinr said:
Just in case anyone else is working on this: I noticed that there is an extra HTTP Header that I didn't notice before in the initial login called "AppToken". It's a base64 encoded version of this:

Code:
SmartPhoneKeyVersion=1;SmartPhoneType=ANDROID;UUID=<my Phones UUID>

So it seems this header has to be added to any requests and it treats it as the "authentication":

There is also another header called AccessKeyID:
Code:
AccessKeyID:      A1r619u1ty!

BOTH of these new headers have to be present to access the new service.

-Jeremy

thanks Jeremy. For some reason the old APIs (https://nissan-na-smartphone-biz.viaaq.com/aqPortal/smartphoneProxy/) still seems to be working and I just tested and most of the functionality is fine (login, request update, Start climate control). Is that expected, one of your earlier post suggested it should not be working.

Just to make sure my app is future proof I tried the new v3 api with your suggestions on AccessKeyId and AppToken in headers and I am still getting "This request requires HTTP authentication" error message. Any suggestion on how to proceed or a sample trace like IIama suggests would be helpful as well.

thanks!

So I don't know if the old interface is "supposed" to still be working, but it stopped for me... But I'm also a "secondary" driver on our car, my GF is the primary, so I also lost the ability to control the car online via the Nissan website.

However the new interface works fine for me now, so I don't know why I got locked out of the old one but the new one works. I can only speculate at this point.

As far as a trace, I have not performed a trace, but here's the Linux cURL command that works for me:

Code:
curl -c cookies.txt -H "AccessKeyID: A1r619u1ty!" -H "AppToken: <Base 64 of token>"  [email protected] https://nissan-na-smartphone-biz.viaaq.com/aqPortal/v3/smartphoneProxy/userService


Where "login.xml" contains:

Code:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?><ns2:SmartphoneLoginWithAdditionalOperationRequest xmlns:ns2="urn:com:airbiquity:smartphone.userservices:v2" xmlns:ns3="http://www.nissanusa.com/owners/schemas/api/0" xmlns:ns4="urn:com:hitachi:gdc:type:report:v1" xmlns:ns5="urn:com:airbiquity:smartphone.reportservice:v1" xmlns:ns6="urn:com:hitachi:gdc:type:vehicle:v1" xmlns:ns7="urn:com:airbiquity:smartphone.vehicleservice:v1"><SmartphoneLoginInfo><UserLoginInfo><userId>My Email</userId><userPassword>My password</userPassword></UserLoginInfo><DeviceToken>My Token</DeviceToken><UUID>My UUID</UUID><Locale>en_US</Locale><AppVersion>3.0.2</AppVersion><SmartphoneType>ANDROID</SmartphoneType></SmartphoneLoginInfo><SmartphoneOperationType>SmartphoneGetPreferencesRequest</SmartphoneOperationType><SmartphoneOperationType>SmartphoneLatestBatteryStatusRequest</SmartphoneOperationType><SmartphoneOperationType>SmartphoneLatestACStatusRequest</SmartphoneOperationType><SmartphoneOperationType>SmartphoneGetScheduledACRemoteRequest</SmartphoneOperationType></ns2:SmartphoneLoginWithAdditionalOperationRequest>

Hopefully that helps...
-Jeremy
 
Anyone else *not* getting the "this request requires HTTP authentication" using the v3 URL and the curl that Jeremy shows above? I can't seem to get anything besides this error response. The old endpoint is working fine for me (for example, pycarwings works for me).

Is what I'm doing right for the various fields:


  • - Random number for the DeviceToken
    - 40 char hexadecimal string for the UUID
    - base64 encoded header AppToken, with the above UUID embedded as described
 
Hi all,

I suddenly started getting HTTP 500 "Internal Server Error" responses from both my scripted Carwings API calls and from "unofficial" apps on my phone, yet the official apps and the Nissan web site seemed to be updating fine. Odd.

So, I set up a proxy to look at the traffic, and saw that the official iOS app ("NissanConnect EV") is connecting to a different URL endpoint and speaking JSON rather than XML. The new endpoint I see is: https://gdcportalgw.its-mo.com All API calls seem to be HTTP GET requests, and all parameters are on the query string.

Is anyone else familiar with this 'new' API? I see no mention of it anywhere on the web. I'm wondering if I need to try to figure it out and modify my scripts to use it rather than the old one that speaks XML.

Thanks!
 
Back
Top