I have tried this but its returning this
`%HTTPoison.Response{
body: "{\"name\":\"Bad Request\",\"debug_id\":\"c56c9c74dd210\",\"message\":\"java.lang.IllegalArgumentException\",\"details\":[]}",
headers: [
{"Connection", "keep-alive"},
{"Content-Length", "109"},
{"Content-Type", "application/json"},
{"Server", "nginx/1.18.0 (Ubuntu)"},
{"Cache-Control", "max-age=0, no-cache, no-store, must-revalidate"},
{"Paypal-Debug-Id", "c56c9c74dd210"},
{"Strict-Transport-Security", "max-age=31536000; includeSubDomains"},
{"Edge-Control", "max-age=0"},
{"Accept-Ranges", "bytes"},
{"Date", "Sat, 28 May 2022 20:00:40 GMT"},
{"Via", "1.1 varnish"},
{"X-Served-By", "cache-lhr7375-LHR"},
{"X-Cache", "MISS"},
{"X-Cache-Hits", "0"},
{"X-Timer", "S1653768040.137049,VS0,VE373"}
],
request: %HTTPoison.Request{
body: "{\"grant_type\":\"client_credentials\"}",
headers: [
{"Content-Type", "x-www-form-urlencoded"},
{"Authorization",
"Basic QVdHNEpyQ2twTW1QOFROeXROY1FxbmpMOWN4bmNmY2diMmtpX2NPTWtfTEZGbVZCdVVDUU5fUFZabDhqRU86RUNzYVNqZ2t"}
],
method: :post,
options: [],
params: %{},
url: "https://api-m.sandbox.paypal.com/v1/oauth2/token"
},
request_url: "https://api-m.sandbox.paypal.com/v1/oauth2/token",
status_code: 400
}
[info] Sent 200 in 1282ms
^[[2A
`
The way around I’m using now is
`{res,_}=System.cmd "curl", ["POST", "-H", "Accept: application/json","-H", "Accept-Language: en_US", "https://api-m.sandbox.paypal.com/v1/oauth2/token", "-d", "grant_type=client_credentials","-u", "username:password"]
token_map=
res |> String.replace("'", "\"") |> Poison.decode!()`