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
0 answers

How can i do parallel requests with rust and collect the results afterwards?

so far ive tried this but it turned out to be slower than the original one. https://gist.github.com/SkyBlockDev/ff4b81f45ed284fe6a31b63926cc9de3 Couldn't find any other way of doing this while being able to keep the results. i was originally doing…
tricked
  • 11
  • 1
  • 2
0
votes
1 answer

Clone reqwest response

I'm currently trying to test an API endpoint using actix-web and reqwest. I can insert some records (using sqlx), and then make the request and check it returned a 200 HTTP status, and corroborate that the returned data belongs to the user created -…
0
votes
0 answers

reqwest::blocking no method named `text` found

I am trying to use the reqwest::blocking example, and I am encountering an error. Firstly, "the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`) cannot use the `?`…
0
votes
1 answer

How to return an array of objects queried from external API in Rocket

I'm new to Rust, and wanted to test it out with something simple. The code basically queries an external API and returns the response. In this case, the response is an array of objects. #![feature(proc_macro_hygiene, decl_macro)] #[macro_use]…
kue
  • 341
  • 1
  • 4
  • 11
0
votes
1 answer

using reqwest crate for oauth2 authentication - redirect_uri_mismatch

I'm using reqwest to authenticate users using google oauth. I have set the credentials correctly (client_id, secret, redirect_uris) but I still cannot exchange the code that I get from google to get the tokens. let mut params =…
0
votes
1 answer

Rust hit an API that returns an array of arrays

I am new to rust and working on a tool which interacts with the Binance API. The API returns a response like so: { "lastUpdateId": 1027024, "bids": [ [ "4.00000000", // PRICE "431.00000000" // QTY ] ], "asks": [ …
Spikerr
  • 311
  • 1
  • 5
  • 16
0
votes
0 answers

Return type errors making a POST request using reqwest in Rust

I'm new to Rust and Typed languages and am having trouble making a post request using reqwest in Rust. I'm not sure which arguments I should pass in to the Result return type enum. I'm also not sure if my approach so far is the right on because I…
AMP_035
  • 167
  • 1
  • 2
  • 13
0
votes
1 answer

reqwest send multipart form with very large attachment

As this answer explains, it's possible to use Body::wrap_stream(read_stream) to POST the contents of a file without first reading the entire contents into memory. How can we do the same thing as part of a reqwest::multipart::Form? The following…
Eric
  • 11,392
  • 13
  • 57
  • 100
0
votes
1 answer

Reqwest request not getting my reqwest::Client's default headers

I am trying to write a library that communicates with Todoist's REST API. The idea is that the library exposes a TodoistAPI struct that contains a reqwest::Client and a base_url. There is a new() function that returns the an instantiated TodoistAPI…
0
votes
1 answer

Detecting a ConnectionReset in Rust, instead of having the Thread panic

So I have a multi-threading program in Rust, which sends Get Requests to my Website, and I'm wondering how I can detect a ConnectionReset. What I'm trying to do is, after the request, check if there was a ConnectionReset, and if there was, wait for…
Tayhay
  • 3
  • 3
0
votes
1 answer

What happens if more data than the Content-Length is transferred (to the client)?

I'm working on a server that accepts a URL from a user and downloads it (and does other stuff to it ofc like uploading it back but that's irrelevant here). The maximum file size it should accept is 4 GB which is why the Content-Length MUST exist for…
0
votes
0 answers

Tokio 1.0.1 and reqwest 0.10.10 fail: not currently running on the Tokio runtime

I am translating code to version 1.0.1 of Tokio and version 0.10.10 of reqwest. This code does not work: // Cargo.toml dependencies: // reqwest = "0.10.10" // tokio = { version = "1.0.1", features = ["full"] } #[tokio::main] async fn main() { …
Petr Kozelka
  • 7,670
  • 2
  • 29
  • 44
0
votes
1 answer

How can I get JSON from the Github API?

I just want to get a JSON from the following URL. So I used this code: extern crate reqwest; fn main() -> Result<(), Box> { let res = reqwest::Client::new() .get("https://api.github.com/users/octocat") …
0
votes
1 answer

reqwest example POST request not compiling

I tried to complied the following reqwest example: let client = reqwest::Client::new(); let res = client.post("http://httpbin.org/post") .body("the exact body that is sent") .send()?; The example fails to compile: error[E0277]: the `?`…
dev
  • 95
  • 2
  • 12
0
votes
0 answers

How to send proper HTTP request and handle the response?

I have written a function to send a POST request: pub async fn make_login_request( client: &Client, host: &String, credentials: &HashMap, ) -> Result<(), reqwest::Error> { client .post( …
Harshit
  • 5,147
  • 9
  • 46
  • 93