« first day (1877 days earlier)      last day (1611 days later) » 

6:11 AM
The expression isn't misguided. IMO it's a strong expression of intent and it reveals a very different approach than the ones you find in other languages where adding an abstraction most often comes with an additional cost. I'm all for clarity but I don't understand all those excuses. There's no problem with the expression.
 
6:24 AM
How can I convert above code into rust.
I have tried something as below
pub struct ToSend {
data: Data,
}

pub struct Data {
field1: String,
field2: String,
}

let field1 = "value1";
let field2 = "value2";

let data = Data {
field1,
field2,
};

let data = serde_urlencoded::to_string(&data).expect("serialization error");

let mut request = Request::new(reqwest::Method::POST, url);
*request.body_mut() = Some(data.into());

self.inner
.execute(request)
.and_then(move |response: Response| {
 
6:49 AM
@ravi As mentioned yesterday, you need to set a header. Something like request.headers_mut().insert(reqwest::header::CONTENT_TYPE, "application/x-www-form-urlencoded");
 
@loganfsmyth No that's not the issue. I am already setting it.
Issue is I need to get
{"field1": "value1", "field2": "value2"}
 
alright good to know. Your code above doesn't include that, so perhaps it would be good to make a full example?
How is your code setting the header? If it's not set, the server won't know what you're sending and won't know what to do with your data
 
Ohh I am not setting any header
let data = serde_urlencoded::to_string(&data).expect("Serialization bug");
I am using this
@loganfsmyth Thank you man. Just a minor mistake and so much time spent...
:)
 
7:26 AM
@ravi Great, glad that helped. Encoding the data is important, but you also have to tell the server how you encoded it, or else it won't know how to decode it :)
 
 
3 hours later…
10:03 AM
@DenysSéguret That's in line with my thoughts, sure. But I suppose there will always be someone we can't please. :/
Nevertheless, ZCA is actually worth adding to the Rust tropes site. Plus clippy.
 
 
14 hours later…

« first day (1877 days earlier)      last day (1611 days later) »