I'm having trouble making a POST request with an XML body via the reqwest
crate. For now, I'm just passing a formatted String
to the body
method, kind of like this:
let body = format!(r#"<?xml version="1.0" encoding="UTF-8"?>
<Example>
<DummyData>Foo</DummyData>
<DummyInt>{}</DummyInt>
</Example>
"#, 5)
let client = blocking::Client::builder()
.user_agent(APP_USER_AGENT)
.build()?
let res = client
.post(url)
.body(body) // passing my String to the body method, problem is here
.send()
.unwrap();
I'm getting a status code of 415 with an "Unsupported Media Type" error message which occurs when the payload format is unsupported by the server. I know for sure the issue is with my code because I can call this same API with Node.js and include a string template literal and it works fine.