Forum rules
Under no circumstances is spamming or advertising of any kind allowed. Do not post any abusive, obscene, vulgar, slanderous, hateful, threatening, sexually-orientated or any other material that may violate others security. Profanity or any kind of insolent behavior to other members (regardless of rank) will not be tolerated. Remember, what you don’t find offensive can be offensive to other members. Please treat each other with the kind of reverence you’d expect from other members.
Failure to comply with any of the above will result in users being banned without notice. If any further details are needed, contact: “The team” using the link at the bottom of the forum page. Thank you.
User avatar
vankasteelj
Posts: 151
Joined: Sun Nov 15, 2015 1:09 am

Re: [OS] Brand new REST API for testing

Sat Feb 20, 2021 9:04 pm

Hi, I'm having troubles with the new api.

I'm getting back a 503 Backend fetch failed on every "/download" post-request I make. I'm not sure why, maybe it's just the API having troubles tonight.

Here's the complete request and response:
Image

I'm developing a nodejs wrapper (opensubtitles-api) compatible with the new api, it's a WIP available at https://github.com/vankasteelj/opensubtitles-api/tree/REST

I also have a question: why force form-data when json is much more friendly? Json is working for /login though, but not for /download. It doens't accept another Content-Type than form-data. It does seem to accept a "json body" though, even if it also gets me to 503. Maybe I'm just not getting form-data...

os_dev
Posts: 68
Joined: Wed Oct 17, 2018 3:42 pm

Re: [OS] Brand new REST API for testing

Sun Feb 21, 2021 6:28 pm

vankasteelj wrote:
I also have a question: why force form-data when json is much more friendly? Json is working for /login though, but not for /download. It doens't accept another Content-Type than form-data. It does seem to accept a "json body" though, even if it also gets me to 503. Maybe I'm just not getting form-data...


So, for the 503.... seems everything is working now...was it temporary for you, or could you get the download to work at some point ?

For the forced formats... I didn't force anything, if you are referring to the docs I just don't know how to display it better in the stoplight.io.... but on the api side, there's no difference in how I get the parameters sent, and no check on the content type, so if a way to post on login works, it should work on the download too..

In ruby I either set the parameters one by one, or send a json body, I don't specify any content type, so I never really asked myself the question

User avatar
vankasteelj
Posts: 151
Joined: Sun Nov 15, 2015 1:09 am

Re: [OS] Brand new REST API for testing

Sun Feb 21, 2021 7:11 pm

Still not working, no.

If I don't set the header to Content-Type : multipart/form-data, it sends back 406. But it does error with 503 Backend fetch fail either with a real form-data POST request or a json-body POST request.

os_dev
Posts: 68
Joined: Wed Oct 17, 2018 3:42 pm

Re: [OS] Brand new REST API for testing

Sun Feb 21, 2021 8:58 pm

vankasteelj wrote:Still not working, no.

If I don't set the header to Content-Type : multipart/form-data, it sends back 406. But it does error with 503 Backend fetch fail either with a real form-data POST request or a json-body POST request.


Can you get the API to work with a testing tool, like postman or insomnia ?

User avatar
vankasteelj
Posts: 151
Joined: Sun Nov 15, 2015 1:09 am

Re: [OS] Brand new REST API for testing

Wed Feb 24, 2021 7:50 pm

os_dev wrote:Can you get the API to work with a testing tool, like postman or insomnia ?


Postman was successfull. Testing with various settings made me realize: the 'Content-Type:multipart/form-data' header isn't necessary, but the 'Accept:*/*' is mandatory. Otherwise it sends back an error 406 with 'Content-Type:application/json' or an error 503 with 'Content-Type:multipart/form-data'.

This should be fixable on your end or stipulated in the docs :)

os_dev
Posts: 68
Joined: Wed Oct 17, 2018 3:42 pm

Re: [OS] Brand new REST API for testing

Wed Feb 24, 2021 11:15 pm

vankasteelj wrote: but the 'Accept:*/*' is mandatory.
This should be fixable on your end or stipulated in the docs :)


Oh I'd be glad to, but I don't understand what you are saying I'm afraid....I don't know how to reproduce the problem you experience.

User avatar
vankasteelj
Posts: 151
Joined: Sun Nov 15, 2015 1:09 am

Re: [OS] Brand new REST API for testing

Wed Feb 24, 2021 11:20 pm

/duplicate/
Last edited by vankasteelj on Wed Feb 24, 2021 11:24 pm, edited 1 time in total.

User avatar
vankasteelj
Posts: 151
Joined: Sun Nov 15, 2015 1:09 am

Re: [OS] Brand new REST API for testing

Wed Feb 24, 2021 11:21 pm

os_dev wrote:Oh I'd be glad to, but I don't understand what you are saying I'm afraid....I don't know how to reproduce the problem you experience.


You must set manually a header 'Accept' to '*/*' otherwise the server doesn't respond something else than an error. Like this:
Image

That header is set automatically by Postman, but not by nodejs modules like Request or Got, so I'm guessing it isnt standard. So the query must actually look like this:
Image

os_dev
Posts: 68
Joined: Wed Oct 17, 2018 3:42 pm

Re: [OS] Brand new REST API for testing

Wed Feb 24, 2021 11:51 pm

as much as I can test now it works with both "*/*" and "application/json" ... but will put a note in the docs to experiment with both in case of problem...

Thanks for pointing it out !

note that the user-agent is not used by the api

Return to “Developing”

Who is online

Users browsing this forum: No registered users and 4 guests