• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

Solved API login problem (invalid character...)

Status
Not open for further replies.

zacy5000

Member
Operating System: Linux
SinusBot Version: 0.9.16-10f0fad

Problem Description
I am trying to log in to SinusBot through the API however I am returned an error no matter what I do. I am posting the data and have tried many ways including online applications.
I am using http://IP:8087/api/v1/bot/login as the URL and am posting username, password, and BotId like the API documentation says. I get the response:
Code:
{"success":false,"code":406,"error":"invalid character 'u' looking for beginning of value"}
If I don't use any parameters for the POST request then I get:
Code:
{"success":false,"code":406,"error":"EOF"}
I was successful using the info part of the API (/api/v1/bot/info) which returned Unauthorized which means the API is working. This shows that the API documentation ( https://www.sinusbot.com/api/ ) URL for logging in might be wrong or that I am doing something wrong.
Any help is appreciated as I have been stuck on this for ages.
Thanks,
Isaac.
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Send us your POST request of you programming language please :) without we cannot do anything^^
 

zacy5000

Member
http://IP:8087/api/v1/bot/login
Post Parameters: username=admin&password=PASSWORD&botId=1
Everything in red is set to the correct thing. It seems this part of the API is the only part that is causing trouble for me.
 

flyth

is reticulating splines
Staff member
Developer
Contributor
You need to send a JSON body, not parameters / urlencoded stuff. :)
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
The Sinusbot API needs JSON so that is the issue :)
 

zacy5000

Member
It worked :D
Thanks so much. Didn't realize they had to be send JSON. I was meant to put I was sending the content type header as x-www-form-urlencoded but forgot but I am glad you figured it out anyway.

One small question, what is bot ID? As in how do I find it. I try logging in and it just says forbidden but I believe that it's because of a incorrect bot ID.
Thanks,
Isaac.
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
The ID is shown in the webinterface under the menu entry Instance settings.
 

zacy5000

Member
Edit: Never mind figured it out.
Turns out I had to find the bot ID using the API "/api/v1/botId" and use that. Instance ID does not work for some reason.
Thanks for all your help :)


Post before:
Ahh so the bot ID is the instance id? I am trying that but it keeps saying forbidden (I am using the admin account).
Heres what I am posting just to make sure I am correct:
"username":sinusBotUsername,
"password":sinusBotPassword,
"botId":"c7Xb4a7X-XXXX-XXXX-XXXX-XXXXXXXXXXXXX"
I replaced most of the characters with X's for the instance ID just in-case its important.
 
Last edited:
Status
Not open for further replies.
Top