Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Model S REST API

This site may earn commission on affiliate links.
I've tried: request.Headers.Add("Authorization: Bearer 121212121212121212")

Same problem.
Starting to doubt the problem is me.

Is it just me, or are the characters ": Bea" being removed when displayed on this forum? These commands appear correct in the quotes when editing, but they are being removed upon display. Very strange.

See this screen shot:

upload_2016-8-9_8-7-22.png
 
Have you tried

Code:
Request.Headers("Authorization")="Bearer 12341234"

Or

Code:
Request.Headers.Add("Authorization", "Bearer 12341234")

If that doesn't work can you do a Fiddler or Wireshark capture? that will show us what the headers in the packet actually look like.
Ok, I have some knowledge of Wireshark, but not enough to know what to look for. I know my code works in getting an access token from Tesla's servers. I ran that code through and had a look in wireshark and couldn't see any signs of packets that had the Tesla servers in the URL. I'm not sure what to look for.
 
Ok, I have some knowledge of Wireshark, but not enough to know what to look for. I know my code works in getting an access token from Tesla's servers. I ran that code through and had a look in wireshark and couldn't see any signs of packets that had the Tesla servers in the URL. I'm not sure what to look for.

This may help
Analyze POST and GET packets using WireShark
and
Here's how inspect packets with Fiddler
Tips for using SPD Workflows to talk to 3rd party web services
 
Even without your program running Wireshark will pick up packets on the wire, the fact that you're not receiving a single packet tells me something is wrong. if you go to add remove programs do you have Winpcap installed? try selecting all interfaces on the interface dialog, if that fails try fidler which requires less networking knowledge.
 
Even without your program running Wireshark will pick up packets on the wire, the fact that you're not receiving a single packet tells me something is wrong. if you go to add remove programs do you have Winpcap installed? try selecting all interfaces on the interface dialog, if that fails try fidler which requires less networking knowledge.
Hi,
So I just got it to work somehow. I don't know what I did but it worked. I used the URL to list vehicles and my Tesla showed up. Great. I tried to honk the horn but got a 404. What is the exact URL I use to honk the horn? I used: https://owner-api.teslamotors.com/api/1/vehicles/123123123/command/honk_horn (123123123 is the car ID)
 
Hi,
So I just got it to work somehow. I don't know what I did but it worked. I used the URL to list vehicles and my Tesla showed up. Great. I tried to honk the horn but got a 404. What is the exact URL I use to honk the horn? I used: https://owner-api.teslamotors.com/api/1/vehicles/123123123/command/honk_horn (123123123 is the car ID)
Nevermind, I somehow figured it out with trial and error. Pretty cool to make my car honk :)

Thanks for all your help L-P-G, it was very much appreciated!
I'll be sure to message you if I have anymore problems with the API.
 
PS: if you want to do some testing on the Summon API against a car with Summon shoot me a PM and we can test it with my car, I have a long driveway.

Thanks.

Thanks for the offer! But to start, I think the best would be to get code that works against the mock backend to also work with the tesla websocket backend and vice versa. I think poking at the summon interfaces of a remote MS would be asking for trouble.....


Do the auth parameters really have to be placed in the query string like that? Attempting to auth is failing on my side due to posting a JSON body instead of in the query string. Does the official API support both?

Fixed this. The other interfaces may have also been failing (with json supplied parameters) due to some extraneous debug code.
 
If most other things work, my first guess would be the number formatting you are using for sending numeric values.
Well for the driver and passenger temps, I'm using just a normal 2 digit integer eg 27. The server returns with a "true" response, but then the temps in the car both move to LOW for driver and passenger. With the pano roof, when I request to move it to 'open' or 'vent' the server returns "unknown_state_requested" I'm following the API to the word. Similar story with the charge limit. I can use the seperate commands to move it to 90 or 100%, but if I want to use a custom percentage when I send the server the request it just moves my charge limit down the the lowest daily limit percentage.
 
Well for the driver and passenger temps, I'm using just a normal 2 digit integer eg 27. The server returns with a "true" response, but then the temps in the car both move to LOW for driver and passenger. With the pano roof, when I request to move it to 'open' or 'vent' the server returns "unknown_state_requested" I'm following the API to the word. Similar story with the charge limit. I can use the seperate commands to move it to 90 or 100%, but if I want to use a custom percentage when I send the server the request it just moves my charge limit down the the lowest daily limit percentage.

What does your request look like? It sounds like you probably aren't sending parameters (because it sounds like parameterless ones work for you).

Here's a curl example sending to my mock endpoint (so i don't need to obfuscate tokens...):

Using JSON:
curl -XPOST https://tesla.flawedmodel.com/api/1/vehicles/1234567890/command/set_charge_limit -H "Authorization: Bearer e01b7d7862eeb7d1cf20a1220c1f328bb1f27de7" -H "Content-Type: application/json" -d "{\"percent\":62}"

Regular URI form encoding:
curl -XPOST https://tesla.flawedmodel.com/api/1/vehicles/1234567890/command/set_charge_limit -H "Authorization: Bearer e01b7d7862eeb7d1cf20a1220c1f328bb1f27de7" -d "percent=60"


Setting temperatures (in Celsius, with .1 precision):

curl -XPOST https://tesla.flawedmodel.com/api/1/vehicles/1234567890/command/set_temps -H "Authorization: Bearer e01b7d7862eeb7d1cf20a1220c1f328bb1f27de7" -d "driver_temp=22.0&passenger_temp=23.1"



Or pano roof (can't remember why, but for arbitrary percent values, the state might need to be "close"):

curl -XPOST https://tesla.flawedmodel.com/api/1/vehicles/1234567890/command/sun_roof_controler -H "Authorization: Bearer e01b7d7862eeb7d1cf20a1220c1f328bb1f27de7" -d "state=close&percent=55"