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

JSON response in Get request in reqwest

Why reqwest return error while trying to .json() the response? Looks like im trying the same as in an example: fn main() -> Result<(), Box> { let resp =…
Kamil Staszewski
  • 303
  • 7
  • 20
2
votes
1 answer

Rust multithreaded HTTP requests, get all data from response?

So I have the following code that sends multithreaded requests to a list of domains. So far I am able to grab individual data from the response, such as the bytes, or the url, or the status code, etc. but not all of them together. I would like to…
RandomUser
  • 77
  • 6
2
votes
1 answer

Why does a reqwest response from api.color.pizza return unexpected bytes?

I'm trying to parse the response from a GET request but the output appears to be seemingly random bytes. This problem only occurs when I try this website (https://api.color.pizza/v1/123123) and the response is as expected when trying a different…
2
votes
1 answer

*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely with serde::de::DeserializeOwned struct

I'm attempting to use Iced (UI framework based on The Elm Architecture) with Reqwest (wrapper over hyper) which can use Serde for JSON deserialisation. Independently they work correctly, but I'm new to Rust and something about my implementation is…
GoodEgg
  • 43
  • 5
2
votes
3 answers

Do a synchronous http client fetch within an actix thread

I have an actix endpoint, and I need to do a synchronous http client fetch to get some results, and return some data. My endpoints cannot use async, so I can't use any .await methods. I've tried using reqwests blocking client in my endpoint like…
dessalines
  • 6,352
  • 5
  • 42
  • 59
2
votes
0 answers

How can I get an API's JSON data from a Reqwest response?

I want to get the data from an API: extern crate reqwest; use std::io::Read; pub fn main() { let mut response = reqwest::get("https://api.fcoin.com/v2/market/ticker/ftbtc") .expect("Failed to send request"); let mut buf =…
jie zhang
  • 69
  • 8
1
vote
1 answer

Simpler way to generate json body for reqwest post

I have a post call that adds one line in register, it works but a pain in the back to write and look at. This is how it looks: static CLIENT: Lazy = Lazy::new(|| Client::new()); static GENERATED_TOKEN: Lazy = …
1
vote
1 answer

How to use Reqwest with FCM batch request?

I am trying to implement the Rest HTTP API of FCM batch requests, which is found here. This is the relevant piece of code I am trying to convert with reqwest: curl --data-binary @batch_request.txt -H 'Content-Type: multipart/mixed;…
J. Doe
  • 12,159
  • 9
  • 60
  • 114
1
vote
1 answer

In rust how do I deal with page that ask for javascript?

I'm trying to make a HTTP request in rust using reqwest to get data from a website, similarly to what this command would do ~$ curl -X POST -H "Content-Type: application/json" -d '{"video":""}' watchparty.me/createRoom…
lolozen
  • 386
  • 1
  • 4
  • 19
1
vote
2 answers

Loading fonts at runtime in Rust

I'm working on a Rust desktop application that utilizes the Iced GUI. I use to load a custom font to use for Iced widgets: // fonts module: use iced::Font; pub const NOTO_SANS_REGULAR: Font = Font::External { name: "noto-sans-regular", …
4r7if3x
  • 1,893
  • 1
  • 9
  • 12
1
vote
1 answer

Axum State for Reqwest Client

I am trying to create a shared reqwest Client to be used by request handlers in Axum, but I can't figure out how to add, extract, or wrap it so the type checking on the request handler passes. I tried this: use axum::{extract::State, routing::get,…
Redline
  • 441
  • 8
  • 20
1
vote
2 answers

Force reqwest to periodically re-establish connections for load balancing

I'm writing a high-throughput (>1000 requests per second) REST service in Rust, using reqwest to asynchronously connect to a load-balanced upstream service. To reduce latency of requests to that upstream service, I'm using a long-lived…
Dreamer
  • 1,139
  • 9
  • 18
1
vote
1 answer

How to make some parallel https requests using reqwest?

I need to make 10 parallel requests to the site from different IPs (at the same time). I have an array of 10 proxies, I need to make 10 parallel requests to the site using 1 of 10 proxies for each request in order. #[tokio::main] async fn main() ->…
petgovj
  • 15
  • 2
1
vote
3 answers

Reqwest: read body text and return reqwest::Error

I want to use reqwest to make a request, then print the response's body and return a reqwest::Error if the status code was >= 400. This is how I would like to do this: pub async fn print_body() -> Result<(), reqwest::Error> { let response =…
reqingball
  • 13
  • 4
1
vote
1 answer

error linking with x86_64-w64-mingw32-gcc failed: exit code: 1

I'm trying to make an https request in rust and I have this code: use reqwest::header::{AUTHORIZATION, ACCEPT}; // tokio let's us use "async" on our main function #[tokio::main] async fn main() { let api_url = "https://api.curseforge.com"; …
Rodrigo
  • 84
  • 8