Questions tagged [reqwest]

reqwest is a high-level Rust HTTP client library that aims to be convenient and capable.

Documentation is available at https://docs.rs/reqwest/latest/reqwest/

215 questions
0
votes
1 answer

Why do the bytes of a PNG image downloaded with reqwest differ from those downloaded with Python?

I'm trying to use reqwest library to download a PNG file, but when I download it I see a strange behaviour respect other programming languages like: Python. For instance: let content =…
ALX
  • 19
0
votes
1 answer

Collapse Rust Matching

I am new to rust, and am missing the if let and guard let notation in Swift. I have the following code block: fn some_function() -> Option { let client = reqwest::Client::new(); // res is normally a response type. I've mapped it to an…
Nathan Tornquist
  • 6,468
  • 10
  • 47
  • 72
0
votes
0 answers

Compilation error reqwest::get(url).status()

I am trying to fetch web data in rust by utilizing the reqwest library. I have created the project with Cargo However, whenever I try to compile the code I am getting an error: 7 | let mut response = reqwest::get(url).status(); | …
winsticknova
  • 365
  • 2
  • 5
  • 17
0
votes
1 answer

Is my understanding of the following Rust "reqwest" code correct?

I've been toying around with Rust and have come across the following code: fn request(&url) -> Result<(), Box> { let mut res = reqwest::get(&url)?; let mut body = String::new(); res.read_to_string(&mut body)?; …
Malekai
  • 4,765
  • 5
  • 25
  • 60
0
votes
0 answers

Content-Length header needed error when it is supplied

I am trying to use spotify's Oauth2 but when I try to get the token the response says "411 POST requests require a Content-length header. That’s all we know." but I have added the header to my post request. #[get("/?")] fn spotify_oauth(code:…
Gus
  • 151
  • 2
  • 15
0
votes
3 answers

Adding Headers to a GET Call

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…
simwilso
  • 23
  • 6
0
votes
0 answers

reqwest::client does not have get method

According to this example, I should be able to run get on a client instantiated with client builder: use reqwest::header; let mut headers = header::Headers::new(); headers.set(header::Authorization("secret".to_string())); // get a client…
joydeep bhattacharjee
  • 1,249
  • 4
  • 16
  • 42
0
votes
1 answer

Reqwest's Client::new hangs in test with Iron in a second thread

I'm using Reqwest in my web crawler, and I'm trying to add tests for the main loop to ensure I get correct output. I'm attempting to use Iron for a fake HTTP server, with preset responses. However, in my main_loop function, let client =…
thatlittlegit
  • 69
  • 1
  • 8
0
votes
2 answers

Handling a file upload with reqwest in Javascript

I'm using the following system to handle AJAX uploads: https://github.com/ded/reqwest While it works for everything I've tried so far - I now need to do a file upload (when the input gets changed). How do you go about it? So far I…
Andrew Newby
  • 4,941
  • 6
  • 40
  • 81
0
votes
1 answer

Is there a way I can access a macro from a dependency's dependency without explicitly including it?

Reqwest is built on top of Hyper which includes a header! macro to create custom headers. Is there a way I can access the header! macro without explicitly including Hyper as a separate crate? #[macro_use] extern crate reqwest; header! {…
0
votes
0 answers

Can I create a Body object without copying memory?

I'm trying to implement a PUT request that transmits some bits to a web service: extern crate reqwest; fn put(buf: &[u8]) { let v = Vec::from(buf); let body = ::reqwest::Body::from(v); // execute the request } Is there a way to avoid…
Shmoopy
  • 5,334
  • 4
  • 36
  • 72
0
votes
0 answers

Unable to capture the error when "reqwest" call fails in java script

I'm using "reqwest" to make rest call to service. I'm interested in the error that occur while making a call. Here is my simple exmple
FourOfAKind
  • 2,298
  • 5
  • 31
  • 34
-1
votes
1 answer

How can I fix my error 'thread 'rocket-worker-thread' panicked at 'called `Option::unwrap()` on a `None` value', src\main.rs:25:44'?

I'm coding a basic video streaming website, and am having trouble parsing json into rust. When I attempt to access the page 'http://127.0.0.1:8000/genres' I get a 500 response and in the console it says GET /genres text/html: >> Matched:…
prorex
  • 3
  • 2
-1
votes
1 answer

API response is different from expected

I am trying to call an API using this code: let client = reqwest::Client::new(); let request_url = "https://mainnet-algorand.api.purestake.io/idx2/v2/assets/2751733/balances?currency-greater-than=0"; let response = client …
0xsegfault
  • 2,899
  • 6
  • 28
  • 58
-1
votes
1 answer

why am i getting an error that is running for others in rust reqwest?

I an trying to build a webscraper via rust using reqwest library. reqwest = "0.11.10" scraper = "0.12.0" I saw the example here: https://kadekillary.work/post/webscraping-rust/ I tried to do the same thing, but i am getting an error. My code: ` …
1 2 3
14
15