I am new to Rust and trying to call an API using the reqwest
crate.
I want my code to;
- Include with the GET request the 'Content-Disposition: Inline' header.
- Return and print the JSON as text
I'm not sure what I'm doing wrong and hoping someone can help identify it for me.
The request works fine for me in JS and in Postman and returns the array JSON data, also in my RUST code below the request returns a 200 success.
But I can't see the response data
& the remote server responds with the "Content-Disposition"
header default (not 'inline' as I specify).
My Rust Code which compiles fine and seems to send ok:
extern crate reqwest;
use reqwest::header::HeaderName;
use reqwest::header::HeaderValue;
use reqwest::header::ACCEPT;
use reqwest::header::CONTENT_DISPOSITION;
fn main() {
let client = reqwest::Client::new();
let response_text = client
.get("http://nemlog.com.au/show/1h/NEMLOG.json?id1=RRP.DISPATCHPRICE0&k1=vic")
.header(CONTENT_DISPOSITION, "inline")
.header(ACCEPT, "*/*")
.send()
.unwrap();
println!("Response Text: {:#?}", response_text);
}
the response I recieve in the console from the above request is:
Response Text: Response {
url: "http://nemlog.com.au/show/1h/NEMLOG.json?id1=RRP.DISPATCHPRICE0&k1=vic",
status: 200,
headers: {
"date": "Tue, 22 Oct 2019 06:33:45 GMT",
"server": "Apache/2.4.6 (CentOS) PHP/5.4.16 mod_wsgi/3.4 Python/2.7.5",
"content-disposition": "attachment; filename=NEMLOG.json",
"transfer-encoding": "chunked",
"content-type": "text/json; name=\"NEMLOG.json\"",
},
}
The output I wish to see is the inline response from the call which looks like this:
{"SETTLEMENTDATE":"2019-10-22T10:45:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":91.272}
{"SETTLEMENTDATE":"2019-10-22T10:50:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":75.7859}
{"SETTLEMENTDATE":"2019-10-22T10:55:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":74.8683}
{"SETTLEMENTDATE":"2019-10-22T11:00:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":25.14}
{"SETTLEMENTDATE":"2019-10-22T11:05:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":16.4812}
{"SETTLEMENTDATE":"2019-10-22T11:10:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":56.4572}
{"SETTLEMENTDATE":"2019-10-22T11:15:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":38.5679}
{"SETTLEMENTDATE":"2019-10-22T11:20:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":47.5941}
{"SETTLEMENTDATE":"2019-10-22T11:25:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":25.14}
{"SETTLEMENTDATE":"2019-10-22T11:30:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":51.8465}
{"SETTLEMENTDATE":"2019-10-22T11:35:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":71.7957}
{"SETTLEMENTDATE":"2019-10-22T11:40:00Z","REGIONID":"VIC1","RRP.DISPATCHPRICE0":72.0757}