5
Lensflare
208d

Another weird property of the devRant API:

For every POST request the url parameters need to be passed in the http body instead of in the URL, like this:
app=3&user_id=42

Wtf why?

Comments
  • 2
    @retoor no, both is not allowed. The api needs you to put the url params into the body if it‘s POST, otherwise you can put them into the url if it‘s GET or DELETE.
    I haven‘t tried to always put them into the body but that‘s definitely unusual.
    Url params belong in the url, not the body. They are encoded and escaped specifically for the url. I worked with a loooot of rest apis and never had one which required you to put url params into the body.

    I have seen bad apis and good apis. DevRant isn‘t that bad but it definitely has some weird shit, like this one and the other one with the multitype value and the empty string, that I ranted about a few days ago.
  • 1
    Formdata?
  • 1
    @netikras
    Content-Type: application/x-www-form-urlencoded
    :)
  • 0
    Let’s see if I can post a comment with the new sdk…

    Edit is buggy…
    2
  • 0
    Edit test 1
    2
    Yasss! Works! (Was a UI problem)
  • 0
    Another annoying thing:

    The response of the notification feed has a structure with dynamic keys (inside of username_map).
    Those keys are the ids of the users.

    Now I can‘t use a proper type for this because the properties are not known. I need to use a dictionary with string keys instead.

    Another problem is that the user ids are normally integers but in this structure they are strings because they are json keys.

    This is normally solved by structuring it differently: using an array and moving the keys into values for the same key, so that you can decode it in a type.

    *sigh*
  • 0
    @Lensflare you post data in body. You don't query, so query params make no sense. You post the data. In body
  • 0
    @retoor
    It‘s absolutely fine to have url parameters with POST requests, I don‘t know why the devrant api tries to avoid it. It also allows (or requires) url params for DELETE, so why not for POST?

    It would be fine if the params in the body would be json encoded, but they are url encoded. That‘s the weird part.
    I haven‘t tried to json encode them but url encoded does work.
  • 0
    @netikras see my last comment :)
  • 0
    @retoor ok my assumption that it requires url encoded params in the body might be wrong but I made this assumption for two reasons:

    1. I stole it from OmerFlame

    2. It works. Why would it work if it‘s not the intended way? 😅
    That‘s a weird thing in itself.

    Anyway thanks for letting me know that it works in any encoding.

    But I stand by my point: There is nothing wrong in using url query params with POST, especially if you think that it‘s also ok for DELETE.
  • 0
    @retoor btw where did you get your infos from about how to use the API?
  • 2
    @Lensflare sure. But this is the pattern I've seen in many http client libs. And I think I saw it in rfc when I was trying to figure out why my http client won't allownpayloads for GET requests [ftr: not forbidden by rfc ;) ]
  • 0
    A RELIEF FOR CRYPTO SCAM VICTIMS THROUGH SYNACK HACKERS

    I understand the frustration and stress associated with lost funds through investment scams. They got me and did away with almost half a million dollars. Luckily, I have some influences around who introduced me to an organization called Synack Hackers. As specialists in crypto recovery, the team of expert professionals is dedicated to helping individuals and businesses reclaim their lost money lost to investment scams. With their proven track record and exceptional customer service, they are the go-to company for fund recovery in Montreal and beyond. We were able to track them down and got the complete amount. Reach out to Synack Hackers via the following contact information.

    Email: (synackhack{@}tech{-}center{.}com)
Add Comment