Skip to content

Get request encode empty body to "" - Throw 403 forbidden response from some API #61

@samuelroy

Description

@samuelroy

Hi,

I encountered an issue while using your lib to consume API.ai's api. A GET request is actually sending double quotes in body. After hours of debugging (I thought something was wrong with the headers sent), I found that we encode an empty body with Poison.encode even for a GET request.

This behavior causes API.ai to throw a 403 forbidden response.

I'm doing my first step in Elixir and functional programming, so I lack deep knowledge in how to solve in good manner this issue. Below is my attempt:

adapters/httpoison_adapter.ex, line ~24:

     def process_request_body(""), do: "" #tried to return nil but it's not catched by hackney library
     
     def process_request_body(body), do: Poison.encode!(body)

You can check this behavior using http://requestb.in/ and looking at the raw body of your GET request. it should be empty, it's not.

Looking for your advice and a proper fix!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions