Access token error

Trying to test the access via test but getting below error. My jason sytanx exactly as got from curl details with username/pw/secreat/deviceid/cid etc…

error code 400 - Undocumented Error:
content-length: 89

Appreciate your help.

Thanks

Testing in Demo
https://demo.tradovateapi.com/v1/auth/accesstokenrequest

sytax used as provided in curl details from online api access page
{
“name”: \”username",
“password”: \”pw",
“appId”: \”XXXDEMO",
“appVersion”: “0.0.1”,
“deviceId”: \”1234566-xyzr-didud-e7d8-f2971395d20c",
“cid”: \”XX",
“sec”: \”secretkey"
}

{
“name”: \”username",
“password”: \”pw",
“appId”: \”XXXDEMO",
“appVersion”: “0.0.1”,
“deviceId”: \”1234566-xyzr-didud-e7d8-f2971395d20c",
“cid”: \”99",
“sec”: \”secretkey"
}

i also tried by removing all “” slashes as well… getting the same length error code

Appreciate your help as I’m not a coder !

Hi again @kaygee,
The situation with cURL is this - you need to backslash in front of each " mark. That should make the request succeed for cURL.

Hi Alex,
I did with “” in the syntax as below: Still it is giving the content-length: 89 - error 400.

“{
“name”: \”name”,
“password”: \”pw",
“appId”: \”appid",
“appVersion”: “0.0.1”,
“deviceId”: “0a401aae-6859-26e9-e7d8-f2971395d20c”,
“cid”: “59”,
“sec”: \”secretykey"
}"

Thanks

somehow the \ at the end of each key is getting
removed while pasting it here…

Try:

“{
\“name\”: \”name\”,
\“password\”: \”pw\",
\“appId\”: \”appid\",
\“appVersion\”: \“0.0.1\”,
\“deviceId\”: \“0a401aae-6859-26e9-e7d8-f2971395d20c\”,
\“cid\”: \“59\”,
\“sec\”: \”secretykey\"
}"

Thanks. I tried but getting the same error code 400 - content-length: 89

Any help please ?

Thanks

I think cid is meant to be a number. You are currently passing it as a string. Try the below (note, I’ve removed the quotation marks from the cid field):

"{
\"name\": \"name\",
\"password\": \"pw\",
\"appId\": \"appid\",
\"appVersion\": \"0.0.1\",
\"deviceId\": \"0a401aae-6859-26e9-e7d8-f2971395d20c\",
\"cid\": 59,
\"sec\": \"secretykey\"
}"

Thanks but no luck…tried without quotation for CID. Also without quotations in the beginning and end of the syntax. No luck for far and the same content length error.

Thanks

Have you tried generating a token from the API doc page? Tradovate API

That way you can rule out issues with your JSON data. If you click the “Interact” button on the right side of the page, then “Try it out”, you can edit all the fields in the request body (the ones that say “string”) with your actual values.

When you’re done and click on “Execute” it should return status 200 and a proper response body. If not, something is wrong with your credentials.

this is exactly i’m trying to do in the API doc page to generate a access token. I’m replacing the string with the correct value and credentials but no luck and getting this content length error.
I reset the credentials/API keys multiple time to ensure i have it right but no luck !
Tried with quotation , without quotations etc…
Not sure if i’m missing something or wrong with my keys ?

Thanks

I hate to belabor this, because it seems like you’ve tried everything. But here’s exactly what I see when I use the API docs interactive cURL interface. I’m using Firefox, but it shouldn’t matter.

I don’t add or remove any double-quotes or backslashes. I just replace the words “string” with my credentials. You’ll only need to worry about backslashes when you want to send " characters in your own application or in a command line program.

Once I finish editing, I click the blue button. When the response comes back, I get a 200 code and tokens that expire in 80 minutes.

If you do exactly that and are still getting 400 codes, I have to think something’s wrong with your API access or your credentials. The Tradovate team members will be able to help out with that.

Just did the same way again by replacing the string with my values and credentials. No luck…same error code. I tried by providing wrong credentials and getting the wrong username/pw error. when i changed to the correct credentials then getting the “content length error”. So my credentials are correct but something else… thanks for your help. Let me wait to hear from the Tradovate team on Monday !

Thanks

Hi again @kaygee,

Go to trader.tradovate.com and try generating an API key from there. Follow along with this document to create your API key. Then look closely at the key you’ve generated. There is a link next to the key that will take you to the API docs and pre-authorize requests using your API key. Use this document for guidance.

HI Alex,
I was doing exactly what you have been mentioned here. No luck !

If you use the JSON form below any of the Interact buttons, you should not need any backslashes at all. I also noticed you are using a string for the cid field. Try using no backslashes and change cid to an integer instead of a string.

Access token syntax is working now… Issue was on the pw for the API key…

Thanks

2 Likes