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

Rust request with timeout

When my app starts I need to make a reqwest request every 30 minutes, I tried the loop function with thread::sleep() but when the loop function starts, my main code stops. This is my main.rs file .setup(|app| { let config =…
AmALAks
  • 3
  • 2
0
votes
1 answer

Can't parse JSON from StackAPI: expected value", line: 1, column: 1

I'm trying to parse the JSON from this endpoint: https://api.stackexchange.com/2.2/users/13029516?&site=stackoverflow. It looks like this: { "items": [ { "badge_counts": { "bronze": 27, "silver": 14, "gold": 0 }, "account_id":…
Matthew Trent
  • 2,611
  • 1
  • 17
  • 30
0
votes
1 answer

Why is space traders not taking the Authorization token header?

I am trying to make a spacetraders.io client and when I try to send the token to the endpoint, I get a message saying that I did not send a token. Relevant code: let client = reqwest::Client::new(); let endpoint = "my/agent"; let res =…
0
votes
0 answers

How to print full request text before sending it?

I'm using reqwest to send Post requests to an api behind Cloudflare. The problem is that Cloudflare blocks my requests if it's not in a standard format, even if it deviates slightly from the expected request format (for example, the order of headers…
Gudarzi
  • 486
  • 3
  • 7
  • 22
0
votes
0 answers

test case block if param pass from outside

a strange problem, if get_vec param config pass from outside, test_get_vec current_thread::block_on_all will never ends and do a println. but if I reinit the config param in get_vec, current_thread::block_on_all will get the result and println. i…
weizhao
  • 183
  • 3
  • 16
0
votes
1 answer

Rust: Reqwest Post Request Failing - States Grant_Type Not Supplied in Body (MIME is application/x-www-form-urlencoded)

I am having an issue passing data to Reqwest. I am using serde_urlencoded to create a string for a POST request. I receive the error below. I have confirmed that the data I use for request is correct with curl. It leads me to believe my body or…
Stephen Andary
  • 113
  • 1
  • 10
0
votes
0 answers

Extra quotes in string of parsed JSON response

I'm quite new to rust and try to parse a simple application/json API response into a struct. I'm using reqwest as HTTP client, following my code: main.rs: use reqwest; use serde::Deserialize; #[derive(Deserialize, Debug)] struct HttpbinResponse { …
pfust75
  • 401
  • 1
  • 5
  • 17
0
votes
0 answers

corrupted file when sending it via POST with reqwest

I'm trying to send a POST request to my server including a file. I can do that with curl following this example with no problems https://gokapi.readthedocs.io/en/latest/advanced.html#interacting-with-the-api, but I can't with Rust. When I try to…
Bestfast
  • 1
  • 2
0
votes
0 answers

Using axum and reqwest to upload a file to cloud bucket, streaming it

I've created a small Github repo that mimics exactly what I'm trying to achieve: streaming file uploads to both file systems and the cloud (S3) using axum (and reqwest). I can change all the code you see. There is no restriction. All signatures were…
Fred Hors
  • 3,258
  • 3
  • 25
  • 71
0
votes
1 answer

How to keep both body and headers from a response when using Reqwest?

let req: Request = client.get("https://someaddress").build().unwrap(); let resp = client.execute(req).await.unwrap(); let response_headers = resp.headers(); let response_text = resp.text().await.unwrap(); // cannot move out of `resp` because it is…
0
votes
3 answers

How do you get multiple urls at the same time in a synchronus function

I am getting data from the open weather map API. Currently the data is being retrieved synchronously which is slow. However, the function has to be synchronous as it is part of a library, but it can call an async function. How might I still make…
Star
  • 131
  • 3
  • 18
0
votes
0 answers

How to send large custom struct over HTTP in Rust lang using reqwest, tokio and actix_web

Issue I have a client that needs to send the following custom data structure to an API: #[derive(Serialize, Deserialize)] pub struct FheSum { pub server_keys: ServerKey, pub value1: FheUint8, pub value2: FheUint8, } The code for the…
Patricia
  • 1
  • 3
0
votes
0 answers

Is there a way where I can parse the response body (token) as a string and temporarily store it and call upon that value when needed?

I want to be able to store a bearer token from the response body temporarily for about 900 seconds and be able to use the token whenever another function calls upon it. I have created the basic structure of creating the client and posting the…
0
votes
1 answer

Inserting Json from an api call to a struct but a there is a camp that sometimes is a vec and sometimes is null

i call an api that returns a json like this one [ { "id":"b8b2f91952f1fb757663073fa8f6be73", "name":"test1", "colors":[ { "name":"Red", "number":"0" }, …
GranBoh
  • 67
  • 8
0
votes
0 answers

Getting the error 'unresolved reference: Result' whenever I add the 'reqwest' package. Code compiles but IDE shows as error

When I add the reqwest dependency reqwest = { version = "0.11", features = ["json"] } I start getting an unresolved reference: Result for any Result object fn foo() -> Result<>{} in main.rs. If I remove the "reqwest" dependency, the errors…
juju
  • 884
  • 1
  • 9
  • 31