#server responds with 400 or 403

54 messages · Page 1 of 1 (latest)

orchid summit
#

403 means the auth is received but insufficient. your token is fine, it's just saying you aren't allowed to access that endpoint

#

if you weren't passing a token correctly it'd be 401 instead

violet hearth
#

but why 😭 they gave me this api

#

and I pasted params from their docs

orchid summit
#

it's a permissions issue

violet hearth
#

how can I fix it? is there any library that will help me bypass?

orchid summit
#

no

violet hearth
#

so its their fault?

orchid summit
#

probably not

#

the token you gave isn't allowed to access whatever api you tried to use

#

either fix that externally (did you set permissions correctly?) or just.. don't use apis you can't access

#

it's like you're trying to send a message in an announcement channel that's locked to moderators

#

you can't bypass that

#

as for 400, that indicates the format/content of your message is invalid
check your data, and check how you're passing it
make sure you're using the body if it wants the body, or params if it wants params, and make sure you're setting the appropriate headers if necessary (some clients may set them automatically)

violet hearth
#

bruh

#

oof

#

wait i might be using params when it expects body

#

nah its correct format rip

violet hearth
#

I just enter credentials and they give jwt

orchid summit
#

depends on the service

#

if it's something like discord you could have access to perms, for example

violet hearth
#

nope its just post request with clientId and clientSecret

#

and it returns jwt

orchid summit
#

maybe link to the docs

violet hearth
#

u want link?

orchid summit
#

yeah

violet hearth
#

this is authorization and

#

this is for the request that fails

orchid summit
#

yeah that definitely expects a body, not params

#

the Content-Type header indicates the format of the body, it shows a json body in the example, and the data is structured

violet hearth
#

well i did put the object in body lol

#

but its js object i didnt serialize it

#

axios converts it into json by itself right?

#

chat am I cooked? XD

orchid summit
#

i haven't used axios in so long lol

#

ah ive been misreading the code a bit
you included a lot more context than necessary so ive been reading the earlier request since im on mobile

#

what's requestData?

violet hearth
#

this

#

according to docs i need to send this data in body, and also token in Bearer header

#

I think I need to contact them and ask if they messed up permissions

#

code is correct because its pretty simple one

#

i pasted same json into postman and it fails too

orchid summit
#

the example payload doesn't always work

#

if you're getting 403s with that then the example has stuff that you'd need to change for your own usecase

violet hearth
#

well since its 403 it has no problems with body, but the permissions so I guess it workes ;-;

#

can it be reason that im using localhost?

#

maybe their server blocks every request from http

#

or it doesnt matters?

orchid summit
orchid summit
violet hearth
#

Ok

#

Thanks for help