TMC is an independent, primarily volunteer organization that relies on ad revenue to cover its operating costs. Please consider whitelisting TMC on your ad blocker and becoming a Supporting Member. For more info: Support TMC

Error in Tesla API

Discussion in 'Technical' started by ronaldderksen, Aug 30, 2018.

  1. ronaldderksen

    ronaldderksen Member

    Joined:
    Aug 30, 2018
    Messages:
    5
    Location:
    Netherlands
    Hi,

    Today I noticed that when I use the unofficial tesla API. I get a response like this on vehicle commands:

    <html><head></head><body><p>Our servers are waiting for a supercharger spot..</p></body></html>

    The same call worked yesterday. Doe anybody know what this message means?
    Vehicle state commands are still working.
    The original Tesla app is still working correct.

    What I also tried was using:

    Tesla Model S JSON API · Apiary

    filled in my vehicle id and bearer token and I get above response. When I use the 'Mock server' I get the correct response
     
  2. morder

    morder Member

    Joined:
    Aug 30, 2018
    Messages:
    5
    Location:
    us
    I ran into this issue as well and I added two new headers:

    User-Agent: Mozilla/5.0 (Linux; Android 9.0.0; VS985 4G Build/LRX21Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36

    X-Tesla-User-Agent: TeslaApp/3.4.4-350/fad4a582e/android/9.0.0

    These work and are based on the latest app i've installed. But I'm pretty sure the x-tesla-user-agent could be anything.
     
    • Helpful x 2
    • Informative x 1
  3. ronaldderksen

    ronaldderksen Member

    Joined:
    Aug 30, 2018
    Messages:
    5
    Location:
    Netherlands
    Thank you. I needed to add both headers. It is working again.

    Ronald
     
  4. ronaldderksen

    ronaldderksen Member

    Joined:
    Aug 30, 2018
    Messages:
    5
    Location:
    Netherlands
    Just curious. How did you find these headers? Traffic from app to tesla api is encrypted via tls. On iPhone you cannot place a 'proxy' in the middle because certificates need to be valid.

    Ronald
     
  5. morder

    morder Member

    Joined:
    Aug 30, 2018
    Messages:
    5
    Location:
    us
    I decompiled the APK for android and checked all the outgoing headers and then followed the code to see what their values were. my first thought was that the client keys changed but they're still the same.
     
    • Like x 1
  6. Mexfgzorro

    Mexfgzorro New Member

    Joined:
    Aug 30, 2018
    Messages:
    4
    Location:
    mexico
    problems with vba code help
     
  7. morder

    morder Member

    Joined:
    Aug 30, 2018
    Messages:
    5
    Location:
    us
    I don't know VBA but you don't give us much to go on.
     
  8. markb1

    markb1 Active Member

    Joined:
    Feb 17, 2012
    Messages:
    2,717
    Location:
    San Diego, CA
    That's weird. The API is still working fine for me, and I haven't added those headers. I'm am using a very old client ID, though, so maybe that makes a difference.
     
  9. ronaldderksen

    ronaldderksen Member

    Joined:
    Aug 30, 2018
    Messages:
    5
    Location:
    Netherlands
    Thanks morder,

    I am going for a different approach to get these headers, for future changes. I will try to run a proxy and create signed certificates with my own CA (for the tesla api url). And via DNS redirect traffic to my proxy. I then only need to install my own CA on my own phone. If this works I can log all headers easily.

    Ronald
     
  10. Mexfgzorro

    Mexfgzorro New Member

    Joined:
    Aug 30, 2018
    Messages:
    4
    Location:
    mexico
    My problem,

    when put header

    User-Agent: Mozilla/5.0 (Linux; Android 9.0.0; VS985 4G Build/LRX21Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36

    it's wrong
     
  11. josephyi

    josephyi New Member

    Joined:
    Aug 31, 2018
    Messages:
    3
    Location:
    Fullerton, CA
    In my case, I simply had to add 'user-agent' header to my node client with an arbitrary value. Strangely, postman, curl, ruby, etc. all worked, but there's something weird about node. Anyway, no time to figure it out, here's some copy pasta that you can try

    Code:
    var http = require("https");
    
    var options = {
      "method": "GET",
      "hostname": "owner-api.teslamotors.com",
      "port": null,
      "path": "/api/1/vehicles",
      "headers": {
        "authorization": "Bearer YOUR_TOKEN_HERE",
        'user-agent': '007'
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();
     
    • Funny x 1
  12. JagCesar

    JagCesar New Member

    Joined:
    Nov 29, 2017
    Messages:
    2
    Location:
    Sweden
    Thanks for sharing this guys. I was really scratching my head, I thought my code had somehow changed by itself
     
  13. tpoz

    tpoz Member

    Joined:
    Jun 11, 2018
    Messages:
    5
    Location:
    Portland, OR
    If you have decompiled the code, is it possible to figure out the API calls for the summon feature? It would be great to document those.
     
    • Like x 1
  14. morder

    morder Member

    Joined:
    Aug 30, 2018
    Messages:
    5
    Location:
    us
  15. Jonas_man

    Jonas_man Member

    Joined:
    Sep 1, 2015
    Messages:
    268
    Location:
    Helsinki
    Hey guys while testing my swift lib i noticed that i dont need to add any header besides the content-type. POST and GET works just fine
     
  16. Allante

    Allante Member

    Joined:
    Mar 31, 2016
    Messages:
    98
    Location:
    Greenville, SC
    Does anyone know what happened to the Tim Dorr API page where you can enter code directly into the console view? I know that it has moved to a new site, but it no longer enables you to type directly into the console.

    How can I do this now?
     

Share This Page

  • About Us

    Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.
  • Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


    SUPPORT TMC