Posting compressed binary data via HTTPoison


I need to call a very tricky API.

My non-functioning curl request looked like this:

curl -X POST \
  https://domain.tld \
  -H 'some-header: some-value' \
   -d 'Some\nValue'

After very long debugging, I found a working version:

curl -X POST \
  https://domain.tld \
  -H 'some-header: some-value' \
   --data-binary $'Some\r\nValue'

As you can see, the -d '' was replaced by --data-binary $'' where the normal \n was replaced by \r\n. The --compressed flag also has to be there.

An example of my current setup is:

content = """
"""!(url, content, headers, options)

Now I have no clue how to translate the changes to the curl command to HTTPoison.
Any help is greatly appreciated :slight_smile:

Ok, I figured out the --compressed flag doesn’t need to be there.

Actually, I feel quite stupid now. Got it working.

  1. I had an issue in my actual content string
  2. Just had to pipe my content into |> String.replace("\n", "\r\n").
1 Like