Hi Folks,
I was trying to access the token by calling
https://api-v2.upstox.com/login/authorization/token .
{
"status": "error",
"errors": [
{
"errorCode": "UDAPI10000",
"message": "This request is not supported by Upstox API",
"propertyPath": null,
"invalidValue": null,
"error_code": "UDAPI10000",
"property_path": null,
"invalid_value": null
}
]
}
Unfortunately, I am getting a bad request error from Postman. Could someone please guide me on whatās wrong with my request.
shanmu
September 4, 2023, 7:49am
2
The Content-Type
used for this request is wrong. Please set the content type to application/x-www-form-urlencoded
and try again.
Thanks!!
Worked like a charm. Thank you very much
1 Like
const tokenUrl = āhttps://api-v2.upstox.com/login/authorization/token ā;
const tokenData = {
code,
client_id: apiKey,
client_secret: secretKey,
redirect_uri: redirectUri,
grant_type: āauthorization_codeā
};
const tokenConfig = {
headers: {
āContent-Typeā: āapplication/x-www-form-urlencodedā,
āApi-Versionā: ā2.0ā,
āacceptā: āapplication/jsonā
}
};
axios.post(tokenUrl, querystring.stringify(tokenData), tokenConfig)
.then(response => {
const json_response = response.data;
console.log(JSON.stringify(json_response));
})
.catch(error => {
console.error(error.response.data);
});
shri@shri-HP-EliteBook-840-G3:~/Downloads/upstox$ node login.js
{
status: āerrorā,
errors: [
{
errorCode: āUDAPI100057ā,
message: āInvalid Auth codeā,
propertyPath: null,
invalidValue: null,
error_code: āUDAPI100057ā,
property_path: null,
invalid_value: null
}
]
shanmu
January 17, 2024, 10:58am
5
@mi_unknown
Thank you for reaching out to us.
The error āUDAPI100057ā usually occurs when the authentication code provided to the token API is invalid. This can happen either because the code itself is incorrect or it has been used more than once, as it is intended for a single use only.
For more immediate assistance with errors, you may consult the APIās 4XX response section, where youāll find details on error codes specific to this API.
For general error code information, please visit: Error codes | Upstox Developer API .
We have compiled comprehensive documentation to empower our users to resolve issues independently, without needing extensive support. I highly recommend reviewing each APIās documentation thoroughly before implementation.
However, please remember that we are always here to assist you with any issues you may encounter.
Thank you!
Hi,
Iām getting a similar error on trying to call the token API.
I have reviewed the API a few times now and still getting the same error.
I have set Content-Type and Accepts header values as well. I was trying this in Java just to see if Iām not making a mistake but getting similar issue on Postman.
shanmu
January 19, 2024, 4:15am
7
@natarajmb
Thank you for writing to us.
Could you please share the cURL command for this request so that we can assist you better?
Thank you!
This is the CURL extract from the Postman
curl --location 'https://api-v2.upstox.com/login/authorization/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--header 'Cookie: _cfuvid=Y_Box549krmZ3hHIzGFTkg.RMOAYyjlyBBld8aDpGsk-1705592436713-0-604800000' \
--data-urlencode 'code=0xxx' \
--data-urlencode 'client_id=5c5ea3xx-xxx-xxxx-xxxx-xxxxxxxxx' \
--data-urlencode 'client_secret=9xxxxxxxx' \
--data-urlencode 'redirect_url=https://remote.cloudnative.dev/redirect' \
--data-urlencode 'grant_type=authorization_code'
I have tried with a new endpoint as well and get the same error.
It seems there is a typo in the code related to redirect_uri
. Currently, it is written as redirect_url
. Could you correct it and try again?
I have confirmed and tested the above code by changing the value from redirect_url
to redirect_uri.
duhā¦ apologies I should have checked it before. It works.
I thought I copied it from a sample.
Thanks for confirming. Please migrate your URL from https://api-v2.upstox.com/ to https://api.upstox.com/v2 .