HTTPoison post json

To make an HTTP POST request with JSON payload using HTTPoison in Elixir, you can follow the example below:

# Make sure you have the HTTPoison library installed in your project
# Add it to your mix.exs file:
# defp deps do
#   [
#     {:httpoison, "~> 1.8"}
#   ]
# end

# Import the necessary modules
import HTTPoison.Base
import HTTPoison.Request
import HTTPoison.Response

# Define your JSON payload
payload = %{key1: "value1", key2: "value2"}

# Make the POST request
response ="",
                          [{"Content-Type", "application/json"}])

# Check the response status and body
status_code = response.status_code
body = response.body

# Print the response status code and body
IO.puts("Status Code: #{status_code}")
IO.puts("Response Body: #{body}")

Make sure to replace "" with the actual URL you want to send the POST request to, and adjust the payload map to contain the desired JSON data.

Please note that you need to have the HTTPoison library added as a dependency in your mix.exs file for this code to work.