daaku / syno

Package syno provides a client to access the Synology NAS APIs.
Other
0 stars 1 forks source link

invalid character '<' looking for beginning of value #1

Closed idealhack closed 6 years ago

idealhack commented 6 years ago

This error occurs when I call syno.NewClient().

The reason is Synology returns a HTML (sth. like a splash screen) instead of JSON first, this line would fail and return the error.

When I request the same URL in a browser, it will returns a JSON eventually, even though it's 400, maybe there are some mistakes in my parameters.

I'm new to Synology API, can you reproduce this error? Example code are like:

c, err := syno.NewClient(
    syno.ClientRawURL("https://example.quickconnect.to"),
    syno.ClientLogin(syno.AuthLogin{
        Account: "account",
        Password: "password",
        Session:  "DownloadStation",
        Format:   "cookie",
    }),
)
if err != nil {
    log.Fatalf("error while login to synology: %s", err)
}
log.Println(c)
daaku commented 6 years ago

That may be because the URL you gave the client is for the web UI rather than the API. I no longer have a Synology NAS so can't help diagnose or fix the error unfortunately! Happy to accept a pull request if you figure out a solution :)

idealhack commented 6 years ago

Hi, glad to see your reply!

This issue also been reported in thavel/synolopy#10, it only happen to quickconnect hostnames. It seems that better error message is the best we can do for this situation.

idealhack commented 6 years ago

I'm closing this because clients can't do many things about it.