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
1
vote
1 answer

How to send GET request longer than 65535 symbols from rust?

I am rewriting part of my API from python to rust. In particular, I am trying to make an HTTP request to OSRM server to get a big distance matrix. This kind of request can have quite large URLs. In python everything works fine, but in rust I get an…
Dimitrius
  • 564
  • 6
  • 21
1
vote
1 answer

Testing Content-Type in Response Header

I'm trying to run an integration test for Content-Type in the response. It fails with error: --> tests\greet.rs:18:9 | 5 | let response = client | -------- move occurs because `response` has type `Response`, which does not…
Saurabh
  • 5,176
  • 4
  • 32
  • 46
1
vote
0 answers

Get src parameter value from with scraper

I want to get a url from (inside of src parameter) html tag using scraper. I've tried this code let image_selector = scraper::Selector::parse("#photoInner > ul > li:nth-child(2) > div > img").unwrap(); let mut inner_image: String =…
Marcel Kopera
  • 91
  • 1
  • 7
1
vote
1 answer

Parse json in rust with reqwest and serde_json

I am trying to retrieve and parse a JSON file using reqwest. I used this question as a starting point but it doesn't work with my API. The error: Error: reqwest::Error { kind: Decode, source: Error("expected value", line: 1, column: 1)…
1
vote
1 answer

Send parallel requests and return the first 200 response in rust

I am trying to write a discovery function in Rust that discovers the device IP in LAN, this function should sends HTTP requests for all possible IPs in the IP space and once receives 200 status return the value and cancels all others requests (by…
Murad
  • 13
  • 4
1
vote
1 answer

Reqwest May Not Be Detecting My URL, Request Not Sending Request

reqwest gives me the following error when trying to send a post request: Error: Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("eastus.tts.speech.microsoft.com")), port: None, path:…
sivafe9540
  • 23
  • 7
1
vote
1 answer

Can't return an error from `try_for_each_concurrent` in streams created by reqwest

I'm new to rust, so, perhaps there's a way to do this that i'm not aware of, but, if I convert a reqwest::Body into a stream and invoke, for example, try_for_each_concurrent, the stream's Error type is reqwest::Error, so, I'm expected to return…
1
vote
0 answers

How to get body of response requested with authentication?

When I try to get data from my elasticsearch API the following error appears: thread 'main' panicked at 'failed to get response: reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host:…
Xavi Font
  • 296
  • 4
  • 19
1
vote
1 answer

How to do refresh token in rust with reqwest as http client

I have an API client in my rust project, which is implemented using reqwest. It is using jwt as authorization, and that jwt may expire. Is there any way to do someting like "refresh token and send the request again"? Any hints are welcome.
lockseed
  • 11
  • 1
1
vote
1 answer

Convert Bytes to Buf with bytes library

I'm trying to convert the result of a reqwest file download in to a type which implements the Read trait. Reqwest has given back a Bytes type. Bytes does not seem to implement Read trait but in the same library there is Buf which does implement…
Qwertie
  • 5,784
  • 12
  • 45
  • 89
1
vote
0 answers

TLS error using reqwest "A CA certificate is being used as an end-entity certificate; CaUsedAsEndEntity" for self hosted local CA

My app requires the use of reqwest which throws the error error sending request for url (https://testserver.com/data): error trying to connect: invalid certificate: CAUsedAsEndEntity I have a self hosted test CA, self signed. My environment is…
Mnemosyne
  • 1,162
  • 4
  • 13
  • 45
1
vote
1 answer

Move occurs when using a method that requires ownership

I am using Reqwest to call some APIs. I want to have a general function to parse the response as below: async fn response_to_result(response: &Response) -> anyhow::Result<()> { let status = response.status().as_u16(); let response_message =…
Kingfisher Phuoc
  • 8,052
  • 9
  • 46
  • 86
1
vote
1 answer

'rocket-worker-thread' panicked at 'Cannot drop a runtime in a context where blocking is not allowed'

I'm trying to call a downstream API and return the results as a Json object. I'm using reqwest which uses tokio: Cargo.toml [dependencies] rocket = { version = "0.5.0-rc.1", features = ["secrets", "tls", "json"] } reqwest = { version = "0.11",…
Nightwolf
  • 4,495
  • 2
  • 21
  • 29
1
vote
1 answer

Match the type of a Result<>

Here's an example: #[tokio::main] async fn main() { let args: Vec = env::args().collect(); let body = get_pokemon(&args[1]).await; // here let pokemon = parse_response(body); } struct Pokemon {} async fn…
steamsy
  • 104
  • 1
  • 8
1
vote
2 answers

Dynamically receive json data in rust with reqwest

Ive been trying to receive json data with reqwest and serde but I keep getting the error: Error: reqwest::Error { kind: Decode, source: Error("expected value", line: 1, column: 1) } This is my code so far: #[tokio::main] async fn main() ->…
Leastrio
  • 210
  • 1
  • 2
  • 9